jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageChannelExtract_f.c
author bae
Fri, 15 Oct 2010 10:42:39 +0400
changeset 6814 c6e347fb5b20
parent 5506 202f599c92aa
permissions -rw-r--r--
6725821: Compiler warnings in medialib code Reviewed-by: igor, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, 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
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "mlib_image.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "mlib_ImageCheck.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
typedef union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  double d64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    float f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    float f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  } f32s;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
} d64_2_f32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
void mlib_v_ImageChannelExtract_U8_2_1(mlib_u8  *sl,  mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
                                       mlib_u8  *dl, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
                                       mlib_s32 width, mlib_s32 height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  mlib_u8   *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  mlib_u8   *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  int       i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    mlib_u8  *dend = dl + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    mlib_u32 *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    while (((mlib_addr)sp & 7) > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
      *dp++ = *sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
      sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
      if (dp >= dend) break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    if ((mlib_addr)sp & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
      sp2 = (mlib_u32 *)(sp - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
      for (; dp <= (dend-2); dp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        mlib_u32 s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        s0 = *sp2++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        dp[0] = s0 >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        dp[1] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
      if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        dp[0] = sp2[0] >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
      sp2 = (mlib_u32 *)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
      for (; dp <= (dend-2); dp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        mlib_u32 s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        s0 = *sp2++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        dp[0] = s0 >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        dp[1] = s0 >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
      if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        dp[0] = sp2[0] >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
void mlib_v_ImageChannelExtract_U8_3_2(mlib_u8  *sl, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                                       mlib_u8 *dl, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                                       mlib_s32 width, mlib_s32 height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                                       mlib_s32 count1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  mlib_u8   *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  mlib_u8   *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  mlib_u32  *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
  mlib_u16  *dp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  mlib_u16  *d2end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  mlib_u32  s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  int       i, j, off, count_off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    mlib_u8  *dend  = dl + 2*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    if (count1 == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
      if (dp < dend) *dp++ = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    if ((mlib_addr)dp & 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
      for (; dp <= (dend-2); dp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        dp[0] = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        dp[1] = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        dp[0] = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
      sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
      dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
      continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    dp2 = (mlib_u16*)dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    d2end = (mlib_u16*)((mlib_addr)dend &~ 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    off = (mlib_addr)sp & 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    sp2 = (mlib_u32 *)(sp - off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    switch (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
      case 0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        for (; dp2 <= (d2end-4); dp2 += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
          s0 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
          s1 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
          s2 = sp2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
          dp2[0] = s0 >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
          dp2[1] = (s0 << 8) | (s1 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
          dp2[2] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
          dp2[3] = s2 >>  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
          sp2 += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        for (; dp2 <= (d2end-4); dp2 += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
          s0 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
          s1 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
          s2 = sp2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
          dp2[0] = s0 >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
          dp2[1] = s1 >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
          dp2[2] = (s1 << 8) | (s2 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
          dp2[3] = s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
          sp2 += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
      case 2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        s3 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        for (; dp2 <= (d2end-4); dp2 += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
          s0 = s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
          s1 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
          s2 = sp2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
          s3 = sp2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
          dp2[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
          dp2[1] = s1 >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
          dp2[2] = s2 >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
          dp2[3] = (s2 << 8) | (s3 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
          sp2 += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
      case 3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        s3 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        for (; dp2 <= (d2end-4); dp2 += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
          s0 = s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
          s1 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
          s2 = sp2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
          s3 = sp2[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
          dp2[0] = (s0 << 8) | (s1 >> 24);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
          dp2[1] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
          dp2[2] = s2 >>  8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
          dp2[3] = s3 >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
          sp2 += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    sp = (mlib_u8 *)sp2 + off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    dp = (mlib_u8 *)dp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    while (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
      *dp++ = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
      if (dp < dend) *dp++ = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
      sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
void mlib_v_ImageChannelExtract_U8_4_2(mlib_u8  *sl, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                                       mlib_u8 *dl, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                                       mlib_s32 width, mlib_s32 height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                       mlib_s32 count1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
  mlib_u8   *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  mlib_u8   *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
  mlib_u32  *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
  mlib_u16  *dp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
  mlib_u16  *d2end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
  mlib_u32  s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  int       i, j, off, count_off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    mlib_u8  *dend  = dl + 2*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    if (count1 == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
      if (dp < dend) *dp++ = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
      sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    off = (mlib_addr)sp & 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    if (((mlib_addr)dp & 1) || (off == 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
      for (; dp <= (dend-2); dp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        dp[0] = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        dp[1] = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        sp += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
      if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        dp[0] = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
      sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    dp2 = (mlib_u16*)dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    d2end = (mlib_u16*)((mlib_addr)dend &~ 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    sp2 = (mlib_u32 *)(sp - off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    switch (off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
      case 0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        for (; dp2 < d2end; dp2++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
          s0 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
          dp2[0] = s0 >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
          sp2++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
      case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        for (; dp2 < d2end; dp2++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
          s0 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
          dp2[0] = s0 >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
          sp2++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
      case 2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        for (; dp2 < d2end; dp2++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
          s0 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
          dp2[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
          sp2++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    sp = (mlib_u8 *)sp2 + off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    dp = (mlib_u8 *)dp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
      *dp++ = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
void mlib_v_ImageChannelExtract_32_2_1(mlib_f32 *sp, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                                       mlib_f32 *dp, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                                       mlib_s32 width, mlib_s32 height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
  mlib_d64  *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
  int       i, j, off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    if (((mlib_addr)sp & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
      sp2 = (mlib_d64 *)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        d64_2_f32 d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        d.d64 = sp2[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        dp[i] = d.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
      sp2 = (mlib_d64 *)(sp - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        d64_2_f32 d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        d.d64 = sp2[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        dp[i] = d.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    sp += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    dp += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
void mlib_v_ImageChannelExtract_32_3_1(mlib_f32 *sl, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                                       mlib_f32 *dl, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                                       mlib_s32 width, mlib_s32 height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
  mlib_f32  *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
  mlib_f32  *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
  mlib_d64  *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
  d64_2_f32 d0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
  int       i, j, off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    mlib_f32 *dend = dl + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    if ((mlib_addr)sp & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
      dp[0] = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
      sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      dp ++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    sp2 = (mlib_d64 *)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    for (; dp <= (dend-2); dp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
      d64_2_f32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
      d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
      d1.d64 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
      dp[0] = d0.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
      dp[1] = d1.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
      sp2 += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
      d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
      dp[0] = d0.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
void mlib_v_ImageChannelExtract_32_3_2(mlib_f32 *sl, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                                       mlib_f32 *dl, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                                       mlib_s32 width, mlib_s32 height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                                       mlib_s32 count1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
  mlib_f32  *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
  mlib_f32  *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
  mlib_d64  *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
  d64_2_f32 d0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
  int       i, j, off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    mlib_f32 *dend = dl + 2*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    if (count1 == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      if (dp < dend) *dp++ = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
      sp += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    if ((mlib_addr)sp & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
      if (dp < dend) *dp++ = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
      if (dp < dend) *dp++ = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
      sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    sp2 = (mlib_d64 *)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    for (; dp <= (dend-4); dp += 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      d64_2_f32 d0, d1, d2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
      d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
      d1.d64 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
      d2.d64 = sp2[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
      dp[0] = d0.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
      dp[1] = d0.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
      dp[2] = d1.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
      dp[3] = d2.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
      sp2 += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
      sp = (mlib_f32 *)sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
      *dp++ = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
      if (dp < dend) *dp++ = sp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
      if (dp < dend) *dp++ = sp[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
void mlib_v_ImageChannelExtract_32_4_1(mlib_f32 *sp, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                                       mlib_f32 *dp, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                                       mlib_s32 width, mlib_s32 height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
  mlib_d64  *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
  int       i, j, off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    if (((mlib_addr)sp & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
      sp2 = (mlib_d64 *)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        d64_2_f32 d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        d.d64 = sp2[2*i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        dp[i] = d.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
      sp2 = (mlib_d64 *)(sp - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        d64_2_f32 d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        d.d64 = sp2[2*i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        dp[i] = d.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    sp += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    dp += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
void mlib_v_ImageChannelExtract_32_4_2(mlib_f32 *sl, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                                       mlib_f32 *dl, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                                       mlib_s32 width, mlib_s32 height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                                       mlib_s32 count1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
  mlib_f32  *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
  mlib_f32  *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
  mlib_d64  *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
  int       i, j, off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
  d64_2_f32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    mlib_f32 *dend = dl + 2*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    if (count1 == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
      dp[0] = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
      sp += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
      dp ++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    if (((mlib_addr)sp & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
      sp2 = (mlib_d64 *)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
      for (; dp <= (dend-2); dp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        d64_2_f32 d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        d.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        dp[0] = d.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        dp[1] = d.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        sp2 += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
      if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        dp[0] = d0.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
      sp2 = (mlib_d64 *)(sp - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
      for (; dp <= (dend-2); dp += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        d64_2_f32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        d1.d64 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        dp[0] = d0.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        dp[1] = d1.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        sp2 += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
      if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        dp[0] = d0.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
void mlib_v_ImageChannelExtract_32_4_3(mlib_f32 *sl, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                                       mlib_f32 *dl, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                                       mlib_s32 width, mlib_s32 height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                                       mlib_s32 count1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
  mlib_f32  *sp = sl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
  mlib_f32  *dp = dl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
  mlib_d64  *sp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
  int       i, j, k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
  d64_2_f32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    mlib_f32 *dend = dl + 3*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    for (k = 0; k < count1; k++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
      if (dp < dend) *dp++ = *sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    if (((mlib_addr)sp & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
      sp2 = (mlib_d64 *)sp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
      for (; dp <= (dend-3); dp += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        d64_2_f32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        d1.d64 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        dp[0] = d0.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        dp[1] = d0.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        dp[2] = d1.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        sp2 += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
      if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        *dp++ = d0.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        if (dp < dend) *dp++ = d0.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
      sp2 = (mlib_d64 *)(sp - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
      for (; dp <= (dend-3); dp += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        d64_2_f32 d0, d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        d1.d64 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        dp[0] = d0.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        dp[1] = d1.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        dp[2] = d1.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        sp2 += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
      if (dp < dend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        d0.d64 = sp2[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        d1.d64 = sp2[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        *dp++ = d0.f32s.f1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        if (dp < dend) *dp++ = d1.f32s.f0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    dp = dl += dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
/* general channel extraction: slower due to the inner loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
void mlib_v_ImageChannelExtract_U8(mlib_u8  *src, mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                              mlib_u8  *dst, mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                              mlib_s32 channels, mlib_s32 channeld,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                              mlib_s32 width, mlib_s32 height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                              mlib_s32 cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
  mlib_u8   *sp;              /* pointer for pixel in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
  mlib_u8   *sl;              /* pointer for line in src  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
  mlib_u8   *dp;              /* pointer for pixel in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
  mlib_u8   *dl;              /* pointer for line in dst  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
  int       i, j, k;          /* indices for x, y, channel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
  int       deltac[5] = { 0, 1, 1, 1, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
  int       inc0, inc1, inc2, inc3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
  mlib_u8   s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
  deltac[channeld] = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
  for (i = (channels - 1), k = 0; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    if ((cmask & (1 << i)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
      deltac[k]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
      k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
  deltac[channeld] = channels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
  for (i = 1; i < channeld; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    deltac[channeld] -= deltac[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
  sp = sl = src + deltac[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
  dp = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
/* Only THREE CHANNEL CASE could be executed here!!! */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
  inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
  inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
  inc2 = deltac[3] + inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
  for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
      s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
      dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
      dp[1] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
      dp[2] = s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
      sp   += inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
      dp   += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    sp = sl += slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    dp = dl += dlb;
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
/* general channel extraction: slower due to the inner loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
void mlib_v_ImageChannelExtract_S16(mlib_u16 *src,    mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                                    mlib_u16 *dst,    mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                                    mlib_s32 channels, mlib_s32 channeld,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                                    mlib_s32 width,    mlib_s32 height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                                    mlib_s32 cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
  mlib_u16   *sp;              /* pointer for pixel in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
  mlib_u16   *sl;              /* pointer for line in src  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
  mlib_u16   *dp;              /* pointer for pixel in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
  mlib_u16   *dl;              /* pointer for line in dst  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
  int       i, j, k;          /* indices for x, y, channel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
  int       deltac[5] = { 0, 1, 1, 1, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
  int       inc0, inc1, inc2, inc3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
  mlib_u16   s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
  slb >>= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
  dlb >>= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
  deltac[channeld] = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
  for (i = (channels - 1), k = 0; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    if ((cmask & (1 << i)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
      deltac[k]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
      k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
  deltac[channeld] = channels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
  for (i = 1; i < channeld; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    deltac[channeld] -= deltac[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
  sp = sl = src + deltac[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
  dp = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
  if (channeld == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        s0 = sp[0]; s1 = sp[inc0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        dp[1] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        sp   += inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        dp   += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
      sp = sl = sl + slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
      dp = dl = dl + dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
  } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
  if (channeld == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    inc2 = deltac[3] + inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        dp[1] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        dp[2] = s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        sp   += inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        dp   += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
      sp = sl = sl + slb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
      dp = dl = dl + dlb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
  }}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
/* general channel extraction: slower due to the inner loop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
void mlib_v_ImageChannelExtract_D64(mlib_d64 *src,    mlib_s32 slb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                                    mlib_d64 *dst,    mlib_s32 dlb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                                    mlib_s32 channels, mlib_s32 channeld,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                                    mlib_s32 width,    mlib_s32 height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                                    mlib_s32 cmask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
  mlib_d64   *sp;              /* pointer for pixel in src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
  mlib_d64   *sl;              /* pointer for line in src  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
  mlib_d64   *dp;              /* pointer for pixel in dst */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
  mlib_d64   *dl;              /* pointer for line in dst  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
  int        i, j, k;          /* indices for x, y, channel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
  int        deltac[5] = { 0, 1, 1, 1, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
  int        inc0, inc1, inc2, inc3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
  mlib_d64   s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
  deltac[channeld] = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
  for (i = (channels - 1), k = 0; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    if ((cmask & (1 << i)) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
      deltac[k]++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
      k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
  deltac[channeld] = channels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
  for (i = 1; i < channeld; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    deltac[channeld] -= deltac[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
  sp = sl = src + deltac[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
  dp = dl = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
  if (channeld == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        s0 = sp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        dp[i] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        sp   += channels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
  } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
  if (channeld == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        s0 = sp[0]; s1 = sp[inc0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        dp[1] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        sp   += inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        dp   += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
  } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
  if (channeld == 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    inc0 = deltac[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    inc1 = deltac[2] + inc0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    inc2 = deltac[3] + inc1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
      for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        dp[0] = s0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        dp[1] = s1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        dp[2] = s2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        sp   += inc2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        dp   += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
      sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
      dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
}