jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageChannelInsert_34.c
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * FILENAME: mlib_v_ImageChannelInsert_34.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * FUNCTIONS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *      mlib_v_ImageChannelInsert_U8_34R_A8D1X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *      mlib_v_ImageChannelInsert_U8_34R_A8D2X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *      mlib_v_ImageChannelInsert_U8_34R_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *      mlib_v_ImageChannelInsert_U8_34R
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *      mlib_v_ImageChannelInsert_S16_34R_A8D1X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *      mlib_v_ImageChannelInsert_S16_34R_A8D2X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *      mlib_v_ImageChannelInsert_S16_34R_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *      mlib_v_ImageChannelInsert_S16_34R
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *      mlib_v_ImageChannelInsert_U8_34L_A8D1X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *      mlib_v_ImageChannelInsert_U8_34L_A8D2X8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *      mlib_v_ImageChannelInsert_U8_34L_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *      mlib_v_ImageChannelInsert_U8_34L
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *      mlib_v_ImageChannelInsert_S16_34L_A8D1X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *      mlib_v_ImageChannelInsert_S16_34L_A8D2X4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *      mlib_v_ImageChannelInsert_S16_34L_D1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *      mlib_v_ImageChannelInsert_S16_34L
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * SYNOPSIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * ARGUMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *      src       pointer to source image data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *      dst       pointer to destination image data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *          slb   source image line stride in bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *          dlb   destination image line stride in bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *          dsize       image data size in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *          xsize       image width in pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *          ysize       image height in lines
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *          cmask channel mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * DESCRIPTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *          Insert a 3-channel image into the right or left 3 channels of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *          a 4-channel image low level functions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *                BGR => ABGR   (34R), or       RGB => RGBA     (34L)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * NOTE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *          These functions are separated from mlib_v_ImageChannelInsert.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *          for loop unrolling and structure clarity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#include "vis_proto.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
#define INSERT_U8_34R                                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
  sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
  sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
  sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
  sdl = vis_fpmerge(vis_read_hi(sdh), vis_read_hi(sdh));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
  sdm = vis_fpmerge(vis_read_lo(sdh), vis_read_lo(sdh));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
  dd0 = vis_fpmerge(vis_read_hi(sdl), vis_read_hi(sdj));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
  dd1 = vis_fpmerge(vis_read_lo(sdl), vis_read_lo(sdj));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
  dd2 = vis_fpmerge(vis_read_hi(sdm), vis_read_hi(sdk));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
  dd3 = vis_fpmerge(vis_read_lo(sdm), vis_read_lo(sdk));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#define LOAD_INSERT_STORE_U8_34R_A8                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
  sd0 = *sp++;                                  /* b0g0r0b1g1r1b2g2 */                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  sd1 = *sp++;                                  /* r2b3g3r3b4g4r4b5 */                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  sd2 = *sp++;                                  /* g5r5b6g6r6b7g7r7 */                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  INSERT_U8_34R                                                                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  vis_pst_8(dd0, dp++, bmask);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  vis_pst_8(dd1, dp++, bmask);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
  vis_pst_8(dd2, dp++, bmask);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
  vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
#define LOAD_INSERT_U8_34R                                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  vis_alignaddr((void *)soff, 0);                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
  s0 = s3;                                                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  s1 = sp[1];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  s2 = sp[2];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  s3 = sp[3];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
  sd0 = vis_faligndata(s0, s1);                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
  sd1 = vis_faligndata(s1, s2);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
  sd2 = vis_faligndata(s2, s3);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  sp += 3;                                                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
  dd4 = dd3;                                                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  INSERT_U8_34R
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * Both source and destination image data are 1-d vectors and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * 8-byte aligned. And dsize is multiple of 8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
mlib_v_ImageChannelInsert_U8_34R_A8D1X8(mlib_u8  *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                                                mlib_u8  *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                                                mlib_s32 dsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  mlib_d64  *sp, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
  mlib_d64  sd0, sd1, sd2;          /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  mlib_d64  sde, sdf, sdg, sdh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
  mlib_d64  sdi, sdj, sdk, sdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  mlib_d64  sdm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  int       bmask = 0x77;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
  int       i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
  sp = (mlib_d64 *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  dp = (mlib_d64 *)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  for (i = 0; i < dsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    LOAD_INSERT_STORE_U8_34R_A8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * Either source or destination image data are not 1-d vectors, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * they are 8-byte aligned. And slb and dlb are multiple of 8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * The xsize is multiple of 8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
mlib_v_ImageChannelInsert_U8_34R_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                                                mlib_u8  *dst,  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                                                                mlib_s32 xsize, mlib_s32 ysize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  mlib_d64  *sp, *dp;             /* 8-byte aligned pointer for pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
  mlib_d64  *sl, *dl;             /* 8-byte aligned pointer for line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
  mlib_d64  sd0, sd1, sd2;      /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
  mlib_d64  sde, sdf, sdg, sdh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
  mlib_d64  sdi, sdj, sdk, sdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
  mlib_d64  sdm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  int         bmask = 0x77;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  int       i, j;               /* indices for x, y */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  sp = sl = (mlib_d64 *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
  dp = dl = (mlib_d64 *)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /* 8-byte column loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    for (i = 0; i < xsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
      LOAD_INSERT_STORE_U8_34R_A8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * either source or destination data are not 8-byte aligned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
mlib_v_ImageChannelInsert_U8_34R_D1(mlib_u8  *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                                                            mlib_u8  *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                                            mlib_s32 dsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  mlib_u8   *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
  mlib_u8   *dend, *dend2;      /* end points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
  mlib_d64  *dp;                  /* 8-byte aligned start points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
  mlib_d64  *sp;                  /* 8-byte aligned start point in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  mlib_d64  dd4;                  /* the last datum of the last step */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
  mlib_d64  sde, sdf, sdg, sdh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
  mlib_d64  sdi, sdj, sdk, sdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
  mlib_d64  sdm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
  int       soff;                 /* offset of address in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
  int       doff;                 /* offset of address in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  int       emask;              /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  int         bmask;            /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
  int         i, n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  sa = src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
  da = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
  /* prepare the source address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
  soff  = ((mlib_addr) sa & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
  /* prepare the destination addresses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
  dend  = da + dsize * 4 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
  dend2 = dend - 31;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
  doff  = ((mlib_addr) da & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
  /* set band mask for vis_pst_8 to store the bytes needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
  bmask = 0xff & (0x7777 >> doff) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
  /* generate edge mask for the start point */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
  emask = vis_edge8(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
  /* load 24 bytes, convert to 32 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
  s3 = sp[0];                                   /* initial value */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
  LOAD_INSERT_U8_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
  if (doff == 0) {                              /* dst is 8-byte aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    if (dsize >= 8 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
      vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
      vis_pst_8(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    else {                                      /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
      vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        vis_pst_8(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
          vis_pst_8(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            vis_pst_8(dd3, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /* no edge handling is needed in the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        LOAD_INSERT_U8_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        vis_pst_8(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        vis_pst_8(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
      LOAD_INSERT_U8_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
      vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        vis_pst_8(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
          vis_pst_8(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            vis_pst_8(dd3, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
  else {                                        /* (doff != 0) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    if (dsize >= 8 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
      vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
      vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
      vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    else {                                      /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
              emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
              vis_pst_8(vis_faligndata(dd3, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /* no edge handling is needed in the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        LOAD_INSERT_U8_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
      LOAD_INSERT_U8_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
      vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
      vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
mlib_v_ImageChannelInsert_U8_34R(mlib_u8  *src,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                                                 mlib_u8  *dst,  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                                                         mlib_s32 xsize, mlib_s32 ysize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
  mlib_u8   *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
  mlib_u8   *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
  int         j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
  sa = sl = src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    mlib_v_ImageChannelInsert_U8_34R_D1(sa, da, xsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    sa = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    da = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
#define INSERT_S16_34R                                                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
  vis_alignaddr((void *)0, 6);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
  dd0 = vis_faligndata(sd0, sd0);                 /* b1b0g0r0 */                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
  vis_alignaddr((void *)0, 4);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
  dd1 = vis_faligndata(sd0, sd1);                 /* r0b1gbr1 */                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
  vis_alignaddr((void *)0, 2);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
  dd2 = vis_faligndata(sd1, sd2);                       /* r1b2g2r2 */          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
  dd3 = sd2;                                                          /* r2b3g3r3 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
#define LOAD_INSERT_STORE_S16_34R_A8                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
  sd0 = *sp++;                                          /* b0g0r0b1 */                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
  sd1 = *sp++;                                          /* g1r1b2g2 */                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
  sd2 = *sp++;                                          /* r2b3g3r3 */                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
  INSERT_S16_34R                                                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
  vis_pst_16(dd0, dp++, bmask);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
  vis_pst_16(dd1, dp++, bmask);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
  vis_pst_16(dd2, dp++, bmask);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
  vis_pst_16(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
#define LOAD_INSERT_S16_34R                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
  vis_alignaddr((void *)soff, 0);                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
  s0 = s3;                                                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
  s1 = sp[1];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
  s2 = sp[2];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
  s3 = sp[3];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
  sd0 = vis_faligndata(s0, s1);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
  sd1 = vis_faligndata(s1, s2);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
  sd2 = vis_faligndata(s2, s3);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
  sp += 3;                                                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
  dd4 = dd3;                                                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
  INSERT_S16_34R
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
 * both source and destination image data are 1-d vectors and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
 * 8-byte aligned.  dsize is multiple of 4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
mlib_v_ImageChannelInsert_S16_34R_A8D1X4(mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                                                                 mlib_s16 *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                                                                 mlib_s32 dsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
  mlib_d64  sd0, sd1, sd2;      /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
  int       bmask = 0x07;       /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
  int       i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
  sp = (mlib_d64 *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
  dp = (mlib_d64 *)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
  /* set GSR.offset for vis_faligndata()  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
  /* vis_alignaddr((void *)0, 2); */            /* only for _old */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
  for (i = 0; i < dsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    LOAD_INSERT_STORE_S16_34R_A8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
 * either source or destination image data are not 1-d vectors, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
 * they are 8-byte aligned.  xsize is multiple of 4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
mlib_v_ImageChannelInsert_S16_34R_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                                                                 mlib_s16 *dst,  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                                                                 mlib_s32 xsize, mlib_s32 ysize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
  mlib_d64  sd0, sd1, sd2;      /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
  int       bmask = 0x07;       /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
  int       i, j;               /* indices for x, y */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
  sp = sl = (mlib_d64 *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
  dp = dl = (mlib_d64 *)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    /* 4-pixel column loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    for (i = 0; i < xsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
      LOAD_INSERT_STORE_S16_34R_A8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
 * either source or destination data are not 8-byte aligned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
mlib_v_ImageChannelInsert_S16_34R_D1(mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                                                             mlib_s16 *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                                                             mlib_s32 dsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
  mlib_s16  *sa, *da;           /* pointer for pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
  mlib_s16  *dend, *dend2;      /* end points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
  mlib_d64  *sp;                /* 8-byte aligned start point in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
  mlib_d64  dd4;                /* the last datum of the last step */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
  int soff;             /* offset of address in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
  int doff;             /* offset of address in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
  int       emask;              /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
  int       bmask;              /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
  int       i, n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
  sa = src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
  da = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
  /* prepare the source address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
  soff  = ((mlib_addr) sa & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
  /* prepare the destination addresses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
  dend  = da + dsize * 4 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
  dend2 = dend - 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
  doff  = ((mlib_addr) da & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
  /* set channel mask for vis_pst_16 to store the words needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
  bmask = 0xff & (0x77 >> (doff / 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
  /* generate edge mask for the start point */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
  emask = vis_edge16(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
  /* load 24 byte, convert, store 32 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
  s3 = sp[0];                                   /* initial value */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
  LOAD_INSERT_S16_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
  if (doff == 0) {                              /* dst is 8-byte aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    if (dsize >= 4 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
      vis_pst_16(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
      vis_pst_16(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
      vis_pst_16(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
      vis_pst_16(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    else {                                      /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
      vis_pst_16(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        vis_pst_16(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
          emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
          vis_pst_16(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    /* no edge handling is needed in the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        LOAD_INSERT_S16_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        vis_pst_16(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        vis_pst_16(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        vis_pst_16(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        vis_pst_16(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
      LOAD_INSERT_S16_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
      emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
      vis_pst_16(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        vis_pst_16(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
          emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
          vis_pst_16(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        }
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
  else {                                        /* (doff != 0) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    if (dsize >= 4 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
      vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
      vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
      vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    else {                                      /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
          emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    /* no edge handling is needed in the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        LOAD_INSERT_S16_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        vis_pst_16(vis_faligndata(dd4, dd0), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
      LOAD_INSERT_S16_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
      vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
      emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
      vis_pst_16(vis_faligndata(dd4, dd0), dp++, emask & bmask);
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_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
          emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
          vis_pst_16(vis_faligndata(dd1, dd2), 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_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            vis_pst_16(vis_faligndata(dd2, dd3), 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
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
mlib_v_ImageChannelInsert_S16_34R(mlib_s16 *src,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                                                          mlib_s16 *dst,  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                                                          mlib_s32 xsize, mlib_s32 ysize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
  mlib_s16  *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
  mlib_s16  *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
  int       j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
  sa = sl = src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    mlib_v_ImageChannelInsert_S16_34R_D1(sa, da, xsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    sa = sl = (mlib_s16 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    da = dl = (mlib_s16 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
#define INSERT_U8_34L                                                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
  sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
  sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
  sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
  sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
  sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
  sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
  sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
  sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
  sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
  sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
  sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
  sdl = vis_fpmerge(vis_read_hi(sdh), vis_read_hi(sdh));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
  sdm = vis_fpmerge(vis_read_lo(sdh), vis_read_lo(sdh));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
  dd0 = vis_fpmerge(vis_read_hi(sdj), vis_read_hi(sdl));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
  dd1 = vis_fpmerge(vis_read_lo(sdj), vis_read_lo(sdl));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
  dd2 = vis_fpmerge(vis_read_hi(sdk), vis_read_hi(sdm));                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
  dd3 = vis_fpmerge(vis_read_lo(sdk), vis_read_lo(sdm));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
#define LOAD_INSERT_STORE_U8_34L_A8                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
  sd0 = *sp++;                                  /* b0g0r0b1g1r1b2g2 */                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
  sd1 = *sp++;                                  /* r2b3g3r3b4g4r4b5 */                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
  sd2 = *sp++;                                  /* g5r5b6g6r6b7g7r7 */                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
  INSERT_U8_34L                                                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
  vis_pst_8(dd0, dp++, bmask);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
  vis_pst_8(dd1, dp++, bmask);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
  vis_pst_8(dd2, dp++, bmask);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
  vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
#define LOAD_INSERT_U8_34L                                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
  vis_alignaddr((void *)soff, 0);                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
  s0 = s3;                                                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
  s1 = sp[1];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
  s2 = sp[2];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
  s3 = sp[3];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
  sd0 = vis_faligndata(s0, s1);                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
  sd1 = vis_faligndata(s1, s2);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
  sd2 = vis_faligndata(s2, s3);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
  sp += 3;                                                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
  dd4 = dd3;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
  INSERT_U8_34L
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
 * Both source and destination image data are 1-d vectors and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
 * 8-byte aligned. And dsize is multiple of 8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
mlib_v_ImageChannelInsert_U8_34L_A8D1X8(mlib_u8  *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                                                                mlib_u8  *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                                                                mlib_s32 dsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
  mlib_d64  *sp, *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
  mlib_d64  sd0, sd1, sd2;          /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
  mlib_d64  sde, sdf, sdg, sdh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
  mlib_d64  sdi, sdj, sdk, sdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
  mlib_d64  sdm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
  int         bmask = 0xee;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
  int         i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
  sp = (mlib_d64 *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
  dp = (mlib_d64 *)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
  for (i = 0; i < dsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    LOAD_INSERT_STORE_U8_34L_A8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
 * Either source or destination image data are not 1-d vectors, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
 * they are 8-byte aligned. And slb and dlb are multiple of 8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
 * The xsize is multiple of 8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
mlib_v_ImageChannelInsert_U8_34L_A8D2X8(mlib_u8  *src,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                                                                mlib_u8  *dst,  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                                                        mlib_s32 xsize, mlib_s32 ysize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
  mlib_d64  sd0, sd1, sd2;      /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
  mlib_d64  sde, sdf, sdg, sdh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
  mlib_d64  sdi, sdj, sdk, sdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
  mlib_d64  sdm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
  int         bmask = 0xee;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
  int       i, j;               /* indices for x, y */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
  sp = sl = (mlib_d64 *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
  dp = dl = (mlib_d64 *)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    /* 8-byte column loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    for (i = 0; i < xsize / 8; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
      LOAD_INSERT_STORE_U8_34L_A8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
 * either source or destination data are not 8-byte aligned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
mlib_v_ImageChannelInsert_U8_34L_D1(mlib_u8  *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                                                            mlib_u8  *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                                                            mlib_s32 dsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
  mlib_u8   *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
  mlib_u8   *dend, *dend2;      /* end points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
  mlib_d64  *sp;                /* 8-byte aligned start point in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
  mlib_d64  dd4;                /* the last datum of the last step */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
  mlib_d64  sda, sdb, sdc, sdd; /* intermediate variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
  mlib_d64  sde, sdf, sdg, sdh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
  mlib_d64  sdi, sdj, sdk, sdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
  mlib_d64  sdm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
  int       soff;               /* offset of address in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
  int       doff;               /* offset of address in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
  int       emask;              /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
  int         bmask;            /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
  int         i, n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
  sa = src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
  da = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
  /* prepare the source address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
  soff  = ((mlib_addr) sa & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
  /* prepare the destination addresses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
  dend  = da + dsize * 4 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
  dend2 = dend - 31;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
  doff  = ((mlib_addr) da & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
  /* set band mask for vis_pst_8 to store the bytes needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
  bmask = 0xff & (0xeeee >> doff) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
  /* generate edge mask for the start point */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
  emask = vis_edge8(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
  /* load 24 bytes, convert to 32 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
  s3 = sp[0];                                   /* initial value */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
  LOAD_INSERT_U8_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
  if (doff == 0) {                              /* dst is 8-byte aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    if (dsize >= 8 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
      vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
      vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
      vis_pst_8(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
      vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    else {                                      /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
      vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        vis_pst_8(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
          vis_pst_8(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            vis_pst_8(dd3, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    /* no edge handling is needed in the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        LOAD_INSERT_U8_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        vis_pst_8(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        vis_pst_8(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        vis_pst_8(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        vis_pst_8(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
      LOAD_INSERT_U8_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
      vis_pst_8(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        vis_pst_8(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
          vis_pst_8(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
            vis_pst_8(dd3, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
  else {                                        /* (doff != 0) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    if (dsize >= 8 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
      vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
      vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
      vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    else {                                      /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
      vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
              emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
              vis_pst_8(vis_faligndata(dd3, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    /* no edge handling is needed in the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        LOAD_INSERT_U8_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
      LOAD_INSERT_U8_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
      vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
      emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
      vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
          emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
          vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            emask = vis_edge8(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    }
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
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
mlib_v_ImageChannelInsert_U8_34L(mlib_u8  *src,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                                                         mlib_u8  *dst,  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                                                         mlib_s32 xsize, mlib_s32 ysize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
  mlib_u8   *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
  mlib_u8   *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
  int         j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
  sa = sl = src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    mlib_v_ImageChannelInsert_U8_34L_D1(sa, da, xsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    sa = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    da = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
#define INSERT_S16_34L                                                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
  dd0 = sd0;                                                            /* b0g0r0b1 */        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
  vis_alignaddr((void *)0, 6);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
  dd1 = vis_faligndata(sd0, sd1);                       /* b1gbr1b2 */        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
  vis_alignaddr((void *)0, 4);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
  dd2 = vis_faligndata(sd1, sd2);                         /* b2g2r2b3 */              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
  vis_alignaddr((void *)0, 2);                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
  dd3 = vis_faligndata(sd2, sd2);                         /* b3g3r3r2 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
#define LOAD_INSERT_STORE_S16_34L_A8                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
  sd0 = *sp++;                                          /* b0g0r0b1 */                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
  sd1 = *sp++;                                          /* g1r1b2g2 */                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
  sd2 = *sp++;                                          /* r2b3g3r3 */                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
  INSERT_S16_34L                                                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
  vis_pst_16(dd0, dp++, bmask);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
  vis_pst_16(dd1, dp++, bmask);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
  vis_pst_16(dd2, dp++, bmask);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
  vis_pst_16(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
#define LOAD_INSERT_S16_34L                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
  vis_alignaddr((void *)soff, 0);                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
  s0 = s3;                                                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
  s1 = sp[1];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
  s2 = sp[2];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
  s3 = sp[3];                                                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
  sd0 = vis_faligndata(s0, s1);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
  sd1 = vis_faligndata(s1, s2);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
  sd2 = vis_faligndata(s2, s3);                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
  sp += 3;                                                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
  dd4 = dd3;                                                                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
  INSERT_S16_34L
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
 * both source and destination image data are 1-d vectors and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
 * 8-byte aligned.  dsize is multiple of 4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
mlib_v_ImageChannelInsert_S16_34L_A8D1X4(mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                                                                 mlib_s16 *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                                                                 mlib_s32 dsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
  mlib_d64  sd0, sd1, sd2;      /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
  int       bmask = 0x0e;       /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
  int       i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
  sp = (mlib_d64 *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
  dp = (mlib_d64 *)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
  for (i = 0; i < dsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
    LOAD_INSERT_STORE_S16_34L_A8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
 * either source or destination image data are not 1-d vectors, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
 * they are 8-byte aligned.  xsize is multiple of 4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
mlib_v_ImageChannelInsert_S16_34L_A8D2X4(mlib_s16 *src,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                                                                 mlib_s16 *dst,  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                                                                 mlib_s32 xsize, mlib_s32 ysize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
  mlib_d64  *sp, *dp;           /* 8-byte aligned pointer for pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
  mlib_d64  *sl, *dl;           /* 8-byte aligned pointer for line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
  mlib_d64  sd0, sd1, sd2;      /* source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
  int       bmask = 0x0e;       /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
  int       i, j;               /* indices for x, y */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
  sp = sl = (mlib_d64 *)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
  dp = dl = (mlib_d64 *)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
  /* row loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    /* 4-pixel column loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
    for (i = 0; i < xsize / 4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
      LOAD_INSERT_STORE_S16_34L_A8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
 * either source or destination data are not 8-byte aligned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
mlib_v_ImageChannelInsert_S16_34L_D1(mlib_s16 *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                                                             mlib_s16 *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                                                             mlib_s32 dsize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
  mlib_s16  *sa, *da;           /* pointer for pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
  mlib_s16  *dend, *dend2;      /* end points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
  mlib_d64  *dp;                /* 8-byte aligned start points in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
  mlib_d64  *sp;                /* 8-byte aligned start point in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
  mlib_d64  s0, s1, s2, s3;     /* 8-byte source raw data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
  mlib_d64  sd0, sd1, sd2;      /* 8-byte source data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
  mlib_d64  dd0, dd1, dd2, dd3; /* dst data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
  mlib_d64  dd4;                /* the last datum of the last step */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
  int soff;             /* offset of address in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
  int doff;             /* offset of address in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
  int       emask;              /* edge mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
  int       bmask;              /* channel mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
  int       i, n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
  sa = src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
  da = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
  /* prepare the source address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
  sp    = (mlib_d64 *) ((mlib_addr) sa & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
  soff  = ((mlib_addr) sa & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
  /* prepare the destination addresses */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
  dp    = (mlib_d64 *)((mlib_addr) da & (~7));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
  dend  = da + dsize * 4 - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
  dend2 = dend - 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
  doff  = ((mlib_addr) da & 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
  /* set channel mask for vis_pst_16 to store the words needed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
  bmask = 0xff & (0xee >> (doff / 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
  /* generate edge mask for the start point */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
  emask = vis_edge16(da, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
  /* load 24 byte, convert, store 32 bytes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
  s3 = sp[0];                                   /* initial value */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
  LOAD_INSERT_S16_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
  if (doff == 0) {                              /* dst is 8-byte aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    if (dsize >= 4 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
      vis_pst_16(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
      vis_pst_16(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
      vis_pst_16(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
      vis_pst_16(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
    else {                                      /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
      vis_pst_16(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        vis_pst_16(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
          emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
          vis_pst_16(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    /* no edge handling is needed in the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
        LOAD_INSERT_S16_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
        vis_pst_16(dd0, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        vis_pst_16(dd1, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
        vis_pst_16(dd2, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
        vis_pst_16(dd3, dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
      LOAD_INSERT_S16_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
      emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
      vis_pst_16(dd0, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        vis_pst_16(dd1, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
          emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
          vis_pst_16(dd2, dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
  else {                                        /* (doff != 0) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
    vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
    if (dsize >= 4 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
      vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
      vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
      vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
    else {                                      /* for very small size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
      vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
        emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
          emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
            emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
    /* no edge handling is needed in the loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
    if ((mlib_addr) dp <= (mlib_addr) dend2)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
      n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
      for (i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
        LOAD_INSERT_S16_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
        vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
        vis_pst_16(vis_faligndata(dd4, dd0), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
        vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
        vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
        vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
    if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
      LOAD_INSERT_S16_34L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
      vis_alignaddr((void *)0, -doff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
      emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
      vis_pst_16(vis_faligndata(dd4, dd0), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
      if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
        emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
        if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
          emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
          vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
          if ((mlib_addr) dp <= (mlib_addr) dend)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
            emask = vis_edge16(dp, dend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
            vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
mlib_v_ImageChannelInsert_S16_34L(mlib_s16 *src,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                                                          mlib_s16 *dst,  mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
                                                          mlib_s32 xsize, mlib_s32 ysize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
  mlib_s16  *sa, *da;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
  mlib_s16  *sl, *dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
  int       j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
  sa = sl = src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
  da = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
  for (j = 0; j < ysize; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    mlib_v_ImageChannelInsert_S16_34L_D1(sa, da, xsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
    sa = sl = (mlib_s16 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
    da = dl = (mlib_s16 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
/***************************************************************/