J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | /* |
| 30 | * FUNCTIONS |
| 31 | * mlib_ImageChannelInsert - Copy the source image into the selected |
| 32 | * channels of the destination image |
| 33 | * |
| 34 | * SYNOPSIS |
| 35 | * mlib_status mlib_ImageChannelInsert(mlib_image *dst, |
| 36 | * mlib_image *src, |
| 37 | * mlib_s32 cmask); |
| 38 | * |
| 39 | * ARGUMENT |
| 40 | * dst Pointer to destination image. |
| 41 | * src Pointer to source image. |
| 42 | * cmask Destination channel selection mask. |
| 43 | * The least significant bit (LSB) is corresponding to the |
| 44 | * last channel in the destination image data. |
| 45 | * The bits with value 1 stand for the channels selected. |
| 46 | * If more than N channels are selected, the leftmost N |
| 47 | * channels are inserted, where N is the number of channels |
| 48 | * in the source image. |
| 49 | * |
| 50 | * RESTRICTION |
| 51 | * The src and dst must have the same width, height and data type. |
| 52 | * The src and dst can have 1, 2, 3 or 4 channels. |
| 53 | * The src and dst can be either MLIB_BYTE, MLIB_SHORT, MLIB_INT, |
| 54 | * MLIB_FLOAT or MLIB_DOUBLE. |
| 55 | * |
| 56 | * DESCRIPTION |
| 57 | * Copy the source image into the selected channels of the destination |
| 58 | * image |
| 59 | */ |
| 60 | |
| 61 | #include <stdlib.h> |
| 62 | #include "mlib_image.h" |
| 63 | #include "mlib_ImageCheck.h" |
| 64 | |
| 65 | /***************************************************************/ |
| 66 | /* functions defined in mlib_v_ImageChannelInsert_1.c */ |
| 67 | |
| 68 | void |
| 69 | mlib_v_ImageChannelInsert_U8(mlib_u8 *src, mlib_s32 slb, |
| 70 | mlib_u8 *dst, mlib_s32 dlb, |
| 71 | mlib_s32 channels, |
| 72 | mlib_s32 channeld, |
| 73 | mlib_s32 width, mlib_s32 height, |
| 74 | mlib_s32 cmask); |
| 75 | void |
| 76 | mlib_v_ImageChannelInsert_D64(mlib_d64 *src, mlib_s32 slb, |
| 77 | mlib_d64 *dst, mlib_s32 dlb, |
| 78 | mlib_s32 channels, |
| 79 | mlib_s32 channeld, |
| 80 | mlib_s32 width, mlib_s32 height, |
| 81 | mlib_s32 cmask); |
| 82 | void |
| 83 | mlib_v_ImageChannelInsert_S16(mlib_s16 *src, mlib_s32 slb, |
| 84 | mlib_s16 *dst, mlib_s32 dlb, |
| 85 | mlib_s32 channels, |
| 86 | mlib_s32 channeld, |
| 87 | mlib_s32 width, mlib_s32 height, |
| 88 | mlib_s32 cmask); |
| 89 | void |
| 90 | mlib_v_ImageChannelInsert_S32(mlib_s32 *src, mlib_s32 slb, |
| 91 | mlib_s32 *dst, mlib_s32 dlb, |
| 92 | mlib_s32 channels, |
| 93 | mlib_s32 channeld, |
| 94 | mlib_s32 width, mlib_s32 height, |
| 95 | mlib_s32 cmask); |
| 96 | void |
| 97 | mlib_v_ImageChannelInsert_U8_12_A8D1X8(mlib_u8 *src, |
| 98 | mlib_u8 *dst, |
| 99 | mlib_s32 dsize, |
| 100 | mlib_s32 cmask); |
| 101 | void |
| 102 | mlib_v_ImageChannelInsert_U8_12_A8D2X8(mlib_u8 *src, mlib_s32 slb, |
| 103 | mlib_u8 *dst, mlib_s32 dlb, |
| 104 | mlib_s32 xsize, mlib_s32 ysize, |
| 105 | mlib_s32 cmask); |
| 106 | void |
| 107 | mlib_v_ImageChannelInsert_U8_12_D1(mlib_u8 *src, |
| 108 | mlib_u8 *dst, |
| 109 | mlib_s32 dsize, |
| 110 | mlib_s32 cmask); |
| 111 | void |
| 112 | mlib_v_ImageChannelInsert_U8_12(mlib_u8 *src, mlib_s32 slb, |
| 113 | mlib_u8 *dst, mlib_s32 dlb, |
| 114 | mlib_s32 xsize, mlib_s32 ysize, |
| 115 | mlib_s32 cmask); |
| 116 | void |
| 117 | mlib_v_ImageChannelInsert_U8_13_A8D1X8(mlib_u8 *src, |
| 118 | mlib_u8 *dst, |
| 119 | mlib_s32 dsize, |
| 120 | mlib_s32 cmask); |
| 121 | void |
| 122 | mlib_v_ImageChannelInsert_U8_13_A8D2X8(mlib_u8 *src, mlib_s32 slb, |
| 123 | mlib_u8 *dst, mlib_s32 dlb, |
| 124 | mlib_s32 xsize, mlib_s32 ysize, |
| 125 | mlib_s32 cmask); |
| 126 | void |
| 127 | mlib_v_ImageChannelInsert_U8_13_D1(mlib_u8 *src, |
| 128 | mlib_u8 *dst, |
| 129 | mlib_s32 dsize, |
| 130 | mlib_s32 cmask); |
| 131 | void |
| 132 | mlib_v_ImageChannelInsert_U8_13(mlib_u8 *src, mlib_s32 slb, |
| 133 | mlib_u8 *dst, mlib_s32 dlb, |
| 134 | mlib_s32 xsize, mlib_s32 ysize, |
| 135 | mlib_s32 cmask); |
| 136 | void |
| 137 | mlib_v_ImageChannelInsert_U8_14_A8D1X8(mlib_u8 *src, |
| 138 | mlib_u8 *dst, |
| 139 | mlib_s32 dsize, |
| 140 | mlib_s32 cmask); |
| 141 | void |
| 142 | mlib_v_ImageChannelInsert_U8_14_A8D2X8(mlib_u8 *src, mlib_s32 slb, |
| 143 | mlib_u8 *dst, mlib_s32 dlb, |
| 144 | mlib_s32 xsize, mlib_s32 ysize, |
| 145 | mlib_s32 cmask); |
| 146 | void |
| 147 | mlib_v_ImageChannelInsert_U8_14_D1(mlib_u8 *src, |
| 148 | mlib_u8 *dst, |
| 149 | mlib_s32 dsize, |
| 150 | mlib_s32 cmask); |
| 151 | void |
| 152 | mlib_v_ImageChannelInsert_U8_14(mlib_u8 *src, mlib_s32 slb, |
| 153 | mlib_u8 *dst, mlib_s32 dlb, |
| 154 | mlib_s32 xsize, mlib_s32 ysize, |
| 155 | mlib_s32 cmask); |
| 156 | void |
| 157 | mlib_v_ImageChannelInsert_S16_12_A8D1X4(mlib_s16 *src, |
| 158 | mlib_s16 *dst, |
| 159 | mlib_s32 dsize, |
| 160 | mlib_s32 cmask); |
| 161 | void |
| 162 | mlib_v_ImageChannelInsert_S16_12_A8D2X4(mlib_s16 *src, mlib_s32 slb, |
| 163 | mlib_s16 *dst, mlib_s32 dlb, |
| 164 | mlib_s32 xsize, mlib_s32 ysize, |
| 165 | mlib_s32 cmask); |
| 166 | void |
| 167 | mlib_v_ImageChannelInsert_S16_12_D1(mlib_s16 *src, |
| 168 | mlib_s16 *dst, |
| 169 | mlib_s32 dsize, |
| 170 | mlib_s32 cmask); |
| 171 | void |
| 172 | mlib_v_ImageChannelInsert_S16_12(mlib_s16 *src, mlib_s32 slb, |
| 173 | mlib_s16 *dst, mlib_s32 dlb, |
| 174 | mlib_s32 xsize, mlib_s32 ysize, |
| 175 | mlib_s32 cmask); |
| 176 | void |
| 177 | mlib_v_ImageChannelInsert_S16_13_A8D1X4(mlib_s16 *src, |
| 178 | mlib_s16 *dst, |
| 179 | mlib_s32 dsize, |
| 180 | mlib_s32 cmask); |
| 181 | void |
| 182 | mlib_v_ImageChannelInsert_S16_13_A8D2X4(mlib_s16 *src, mlib_s32 slb, |
| 183 | mlib_s16 *dst, mlib_s32 dlb, |
| 184 | mlib_s32 xsize, mlib_s32 ysize, |
| 185 | mlib_s32 cmask); |
| 186 | void |
| 187 | mlib_v_ImageChannelInsert_S16_13_D1(mlib_s16 *src, |
| 188 | mlib_s16 *dst, |
| 189 | mlib_s32 dsize, |
| 190 | mlib_s32 cmask); |
| 191 | void |
| 192 | mlib_v_ImageChannelInsert_S16_13(mlib_s16 *src, mlib_s32 slb, |
| 193 | mlib_s16 *dst, mlib_s32 dlb, |
| 194 | mlib_s32 xsize, mlib_s32 ysize, |
| 195 | mlib_s32 cmask); |
| 196 | void |
| 197 | mlib_v_ImageChannelInsert_S16_14_A8D1X4(mlib_s16 *src, |
| 198 | mlib_s16 *dst, |
| 199 | mlib_s32 dsize, |
| 200 | mlib_s32 cmask); |
| 201 | void |
| 202 | mlib_v_ImageChannelInsert_S16_14_A8D2X4(mlib_s16 *src, mlib_s32 slb, |
| 203 | mlib_s16 *dst, mlib_s32 dlb, |
| 204 | mlib_s32 xsize, mlib_s32 ysize, |
| 205 | mlib_s32 cmask); |
| 206 | void |
| 207 | mlib_v_ImageChannelInsert_S16_14_D1(mlib_s16 *src, |
| 208 | mlib_s16 *dst, |
| 209 | mlib_s32 dsize, |
| 210 | mlib_s32 cmask); |
| 211 | void |
| 212 | mlib_v_ImageChannelInsert_S16_14(mlib_s16 *src, mlib_s32 slb, |
| 213 | mlib_s16 *dst, mlib_s32 dlb, |
| 214 | mlib_s32 xsize, mlib_s32 ysize, |
| 215 | mlib_s32 cmask); |
| 216 | |
| 217 | /***************************************************************/ |
| 218 | /* functions defined in mlib_v_ImageChannelInsert_34.c */ |
| 219 | |
| 220 | void |
| 221 | mlib_v_ImageChannelInsert_U8_34R_A8D1X8(mlib_u8 *src, |
| 222 | mlib_u8 *dst, |
| 223 | mlib_s32 dsize); |
| 224 | void |
| 225 | mlib_v_ImageChannelInsert_U8_34R_A8D2X8(mlib_u8 *src, mlib_s32 slb, |
| 226 | mlib_u8 *dst, mlib_s32 dlb, |
| 227 | mlib_s32 xsize, mlib_s32 ysize); |
| 228 | void |
| 229 | mlib_v_ImageChannelInsert_U8_34R_D1(mlib_u8 *src, |
| 230 | mlib_u8 *dst, |
| 231 | mlib_s32 dsize); |
| 232 | void |
| 233 | mlib_v_ImageChannelInsert_U8_34R(mlib_u8 *src, mlib_s32 slb, |
| 234 | mlib_u8 *dst, mlib_s32 dlb, |
| 235 | mlib_s32 xsize, mlib_s32 ysize); |
| 236 | void |
| 237 | mlib_v_ImageChannelInsert_S16_34R_A8D1X4(mlib_s16 *src, |
| 238 | mlib_s16 *dst, |
| 239 | mlib_s32 dsize); |
| 240 | void |
| 241 | mlib_v_ImageChannelInsert_S16_34R_A8D2X4(mlib_s16 *src, mlib_s32 slb, |
| 242 | mlib_s16 *dst, mlib_s32 dlb, |
| 243 | mlib_s32 xsize, mlib_s32 ysize); |
| 244 | void |
| 245 | mlib_v_ImageChannelInsert_S16_34R_D1(mlib_s16 *src, |
| 246 | mlib_s16 *dst, |
| 247 | mlib_s32 dsize); |
| 248 | void |
| 249 | mlib_v_ImageChannelInsert_S16_34R(mlib_s16 *src, mlib_s32 slb, |
| 250 | mlib_s16 *dst, mlib_s32 dlb, |
| 251 | mlib_s32 xsize, mlib_s32 ysize); |
| 252 | void |
| 253 | mlib_v_ImageChannelInsert_U8_34L_A8D1X8(mlib_u8 *src, |
| 254 | mlib_u8 *dst, |
| 255 | mlib_s32 dsize); |
| 256 | void |
| 257 | mlib_v_ImageChannelInsert_U8_34L_A8D2X8(mlib_u8 *src, mlib_s32 slb, |
| 258 | mlib_u8 *dst, mlib_s32 dlb, |
| 259 | mlib_s32 xsize, mlib_s32 ysize); |
| 260 | void |
| 261 | mlib_v_ImageChannelInsert_U8_34L_D1(mlib_u8 *src, |
| 262 | mlib_u8 *dst, |
| 263 | mlib_s32 dsize); |
| 264 | void |
| 265 | mlib_v_ImageChannelInsert_U8_34L(mlib_u8 *src, mlib_s32 slb, |
| 266 | mlib_u8 *dst, mlib_s32 dlb, |
| 267 | mlib_s32 xsize, mlib_s32 ysize); |
| 268 | void |
| 269 | mlib_v_ImageChannelInsert_S16_34L_A8D1X4(mlib_s16 *src, |
| 270 | mlib_s16 *dst, |
| 271 | mlib_s32 dsize); |
| 272 | void |
| 273 | mlib_v_ImageChannelInsert_S16_34L_A8D2X4(mlib_s16 *src, mlib_s32 slb, |
| 274 | mlib_s16 *dst, mlib_s32 dlb, |
| 275 | mlib_s32 xsize, mlib_s32 ysize); |
| 276 | void |
| 277 | mlib_v_ImageChannelInsert_S16_34L_D1(mlib_s16 *src, |
| 278 | mlib_s16 *dst, |
| 279 | mlib_s32 dsize); |
| 280 | void |
| 281 | mlib_v_ImageChannelInsert_S16_34L(mlib_s16 *src, mlib_s32 slb, |
| 282 | mlib_s16 *dst, mlib_s32 dlb, |
| 283 | mlib_s32 xsize, mlib_s32 ysize); |
| 284 | |
| 285 | |
| 286 | /***************************************************************/ |
| 287 | |
| 288 | #ifdef MLIB_TEST |
| 289 | mlib_status |
| 290 | mlib_v_ImageChannelInsert(mlib_image *dst, |
| 291 | mlib_image *src, |
| 292 | mlib_s32 cmask) |
| 293 | #else |
| 294 | mlib_status |
| 295 | mlib_ImageChannelInsert(mlib_image *dst, |
| 296 | mlib_image *src, |
| 297 | mlib_s32 cmask) |
| 298 | #endif |
| 299 | { |
| 300 | const mlib_s32 X8 = 0x7; |
| 301 | const mlib_s32 X4 = 0x3; |
| 302 | const mlib_s32 X2 = 0x1; |
| 303 | const mlib_s32 A8D1 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_ONEDVECTOR; |
| 304 | const mlib_s32 A8D2X8 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH8X; |
| 305 | const mlib_s32 A8D2X4 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH4X; |
| 306 | const mlib_s32 A8D2X2 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH2X; |
| 307 | |
| 308 | void *sp; /* pointer for pixel in src */ |
| 309 | void *dp; /* pointer for pixel in dst */ |
| 310 | mlib_s32 ncmask = 0; /* normalized channel mask */ |
| 311 | mlib_s32 channels; /* number of channels for src */ |
| 312 | mlib_s32 channeld; /* number of channels for dst */ |
| 313 | mlib_s32 width, height;/* for src and dst */ |
| 314 | mlib_s32 strides; /* strides in bytes for src */ |
| 315 | mlib_s32 strided; /* strides in bytes for dst */ |
| 316 | mlib_s32 flags; |
| 317 | mlib_s32 flagd; |
| 318 | mlib_s32 dsize; |
| 319 | int i, bit1count = 0; |
| 320 | |
| 321 | MLIB_IMAGE_CHECK(src); |
| 322 | MLIB_IMAGE_CHECK(dst); |
| 323 | MLIB_IMAGE_TYPE_EQUAL(src,dst); |
| 324 | MLIB_IMAGE_SIZE_EQUAL(src,dst); |
| 325 | |
| 326 | channels = mlib_ImageGetChannels(src); |
| 327 | channeld = mlib_ImageGetChannels(dst); |
| 328 | width = mlib_ImageGetWidth(src); |
| 329 | height = mlib_ImageGetHeight(src); |
| 330 | strides = mlib_ImageGetStride(src); |
| 331 | strided = mlib_ImageGetStride(dst); |
| 332 | sp = mlib_ImageGetData(src); |
| 333 | dp = mlib_ImageGetData(dst); |
| 334 | flags = mlib_ImageGetFlags(src); |
| 335 | flagd = mlib_ImageGetFlags(dst); |
| 336 | dsize = width * height; |
| 337 | |
| 338 | /* normalize the cmask, and count the number of bit with value 1 */ |
| 339 | for (i = (channeld - 1); i >= 0; i--) { |
| 340 | if (((cmask & (1 << i)) != 0) && (bit1count < channels)) { |
| 341 | ncmask += (1 << i); |
| 342 | bit1count++; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | /* do not support the cases in which the number of selected channels is |
| 347 | * less than the nubmber of channels in the source image */ |
| 348 | if (bit1count < channels) { |
| 349 | return MLIB_FAILURE; |
| 350 | } |
| 351 | |
| 352 | if (((channels == 1) && (channeld == 1)) || |
| 353 | ((channels == 2) && (channeld == 2)) || |
| 354 | ((channels == 3) && (channeld == 3)) || |
| 355 | ((channels == 4) && (channeld == 4))) { |
| 356 | return mlib_ImageCopy(dst, src); |
| 357 | } |
| 358 | |
| 359 | switch (mlib_ImageGetType(src)) { |
| 360 | case MLIB_BYTE: |
| 361 | if (channels == 1) { |
| 362 | switch (channeld) { |
| 363 | case 2: |
| 364 | if (((flags & A8D1) == 0) && |
| 365 | ((flagd & A8D1) == 0) && |
| 366 | ((dsize & X8) == 0)) { |
| 367 | mlib_v_ImageChannelInsert_U8_12_A8D1X8((mlib_u8 *)sp, |
| 368 | (mlib_u8 *)dp, |
| 369 | dsize, |
| 370 | ncmask); |
| 371 | } |
| 372 | else if (((flags & A8D2X8) == 0) && |
| 373 | ((flagd & A8D2X8) == 0)) { |
| 374 | mlib_v_ImageChannelInsert_U8_12_A8D2X8((mlib_u8 *)sp, strides, |
| 375 | (mlib_u8 *)dp, strided, |
| 376 | width, height, |
| 377 | ncmask); |
| 378 | } |
| 379 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 380 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 381 | mlib_v_ImageChannelInsert_U8_12_D1((mlib_u8 *)sp, |
| 382 | (mlib_u8 *)dp, |
| 383 | dsize, |
| 384 | ncmask); |
| 385 | } |
| 386 | else { |
| 387 | mlib_v_ImageChannelInsert_U8_12((mlib_u8 *)sp, strides, |
| 388 | (mlib_u8 *)dp, strided, |
| 389 | width, height, |
| 390 | ncmask); |
| 391 | } |
| 392 | break; |
| 393 | |
| 394 | case 3: |
| 395 | if (((flags & A8D1) == 0) && |
| 396 | ((flagd & A8D1) == 0) && |
| 397 | ((dsize & X8) == 0)) { |
| 398 | mlib_v_ImageChannelInsert_U8_13_A8D1X8((mlib_u8 *)sp, |
| 399 | (mlib_u8 *)dp, |
| 400 | dsize, |
| 401 | ncmask); |
| 402 | } |
| 403 | else if (((flags & A8D2X8) == 0) && |
| 404 | ((flagd & A8D2X8) == 0)) { |
| 405 | mlib_v_ImageChannelInsert_U8_13_A8D2X8((mlib_u8 *)sp, strides, |
| 406 | (mlib_u8 *)dp, strided, |
| 407 | width, height, |
| 408 | ncmask); |
| 409 | } |
| 410 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 411 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 412 | mlib_v_ImageChannelInsert_U8_13_D1((mlib_u8 *)sp, |
| 413 | (mlib_u8 *)dp, |
| 414 | dsize, |
| 415 | ncmask); |
| 416 | } |
| 417 | else { |
| 418 | mlib_v_ImageChannelInsert_U8_13((mlib_u8 *)sp, strides, |
| 419 | (mlib_u8 *)dp, strided, |
| 420 | width, height, |
| 421 | ncmask); |
| 422 | } |
| 423 | break; |
| 424 | |
| 425 | case 4: |
| 426 | if (((flags & A8D1) == 0) && |
| 427 | ((flagd & A8D1) == 0) && |
| 428 | ((dsize & X8) == 0)) { |
| 429 | mlib_v_ImageChannelInsert_U8_14_A8D1X8((mlib_u8 *)sp, |
| 430 | (mlib_u8 *)dp, |
| 431 | dsize, |
| 432 | ncmask); |
| 433 | } |
| 434 | else if (((flags & A8D2X8) == 0) && |
| 435 | ((flagd & A8D2X8) == 0)) { |
| 436 | mlib_v_ImageChannelInsert_U8_14_A8D2X8((mlib_u8 *)sp, strides, |
| 437 | (mlib_u8 *)dp, strided, |
| 438 | width, height, |
| 439 | ncmask); |
| 440 | } |
| 441 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 442 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 443 | mlib_v_ImageChannelInsert_U8_14_D1((mlib_u8 *)sp, |
| 444 | (mlib_u8 *)dp, |
| 445 | dsize, |
| 446 | ncmask); |
| 447 | } |
| 448 | else { |
| 449 | mlib_v_ImageChannelInsert_U8_14((mlib_u8 *)sp, strides, |
| 450 | (mlib_u8 *)dp, strided, |
| 451 | width, height, |
| 452 | ncmask); |
| 453 | } |
| 454 | break; |
| 455 | |
| 456 | default: |
| 457 | return MLIB_FAILURE; |
| 458 | } |
| 459 | } |
| 460 | else { |
| 461 | if ((channels == 3) && (channeld == 4) && (ncmask == 7)) { |
| 462 | if (((flags & A8D1) == 0) && |
| 463 | ((flagd & A8D1) == 0) && |
| 464 | ((dsize & X8) == 0)) { |
| 465 | mlib_v_ImageChannelInsert_U8_34R_A8D1X8((mlib_u8 *)sp, |
| 466 | (mlib_u8 *)dp, |
| 467 | dsize); |
| 468 | } |
| 469 | else if (((flags & A8D2X8) == 0) && |
| 470 | ((flagd & A8D2X8) == 0)) { |
| 471 | mlib_v_ImageChannelInsert_U8_34R_A8D2X8((mlib_u8 *)sp, strides, |
| 472 | (mlib_u8 *)dp, strided, |
| 473 | width, height); |
| 474 | } |
| 475 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 476 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 477 | mlib_v_ImageChannelInsert_U8_34R_D1((mlib_u8 *)sp, |
| 478 | (mlib_u8 *)dp, |
| 479 | dsize); |
| 480 | } |
| 481 | else { |
| 482 | mlib_v_ImageChannelInsert_U8_34R((mlib_u8 *)sp, strides, |
| 483 | (mlib_u8 *)dp, strided, |
| 484 | width, height); |
| 485 | } |
| 486 | } |
| 487 | else if ((channels == 3) && (channeld == 4) && (ncmask == 14)) { |
| 488 | if (((flags & A8D1) == 0) && |
| 489 | ((flagd & A8D1) == 0) && |
| 490 | ((dsize & X8) == 0)) { |
| 491 | mlib_v_ImageChannelInsert_U8_34L_A8D1X8((mlib_u8 *)sp, |
| 492 | (mlib_u8 *)dp, |
| 493 | dsize); |
| 494 | } |
| 495 | else if (((flags & A8D2X8) == 0) && |
| 496 | ((flagd & A8D2X8) == 0)) { |
| 497 | mlib_v_ImageChannelInsert_U8_34L_A8D2X8((mlib_u8 *)sp, strides, |
| 498 | (mlib_u8 *)dp, strided, |
| 499 | width, height); |
| 500 | } |
| 501 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 502 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 503 | mlib_v_ImageChannelInsert_U8_34L_D1((mlib_u8 *)sp, |
| 504 | (mlib_u8 *)dp, |
| 505 | dsize); |
| 506 | } |
| 507 | else mlib_v_ImageChannelInsert_U8_34L((mlib_u8 *)sp, strides, |
| 508 | (mlib_u8 *)dp, strided, |
| 509 | width, height); |
| 510 | } |
| 511 | else { |
| 512 | |
| 513 | mlib_v_ImageChannelInsert_U8((mlib_u8 *)sp, strides, |
| 514 | (mlib_u8 *)dp, strided, |
| 515 | channels, channeld, |
| 516 | width, height, |
| 517 | ncmask); |
| 518 | } |
| 519 | } |
| 520 | break; |
| 521 | |
| 522 | case MLIB_SHORT: |
| 523 | if (channels == 1) { |
| 524 | switch (channeld) { |
| 525 | case 2: |
| 526 | if (((flags & A8D1) == 0) && |
| 527 | ((flagd & A8D1) == 0) && |
| 528 | ((dsize & X4) == 0)) { |
| 529 | mlib_v_ImageChannelInsert_S16_12_A8D1X4((mlib_s16 *)sp, |
| 530 | (mlib_s16 *)dp, |
| 531 | dsize, |
| 532 | ncmask); |
| 533 | } |
| 534 | else if (((flags & A8D2X4) == 0) && |
| 535 | ((flagd & A8D2X4) == 0)) { |
| 536 | mlib_v_ImageChannelInsert_S16_12_A8D2X4((mlib_s16 *)sp, strides, |
| 537 | (mlib_s16 *)dp, strided, |
| 538 | width, height, |
| 539 | ncmask); |
| 540 | } |
| 541 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 542 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 543 | mlib_v_ImageChannelInsert_S16_12_D1((mlib_s16 *)sp, |
| 544 | (mlib_s16 *)dp, |
| 545 | dsize, |
| 546 | ncmask); |
| 547 | } |
| 548 | else { |
| 549 | mlib_v_ImageChannelInsert_S16_12((mlib_s16 *)sp, strides, |
| 550 | (mlib_s16 *)dp, strided, |
| 551 | width, height, |
| 552 | ncmask); |
| 553 | } |
| 554 | break; |
| 555 | |
| 556 | case 3: |
| 557 | if (((flags & A8D1) == 0) && |
| 558 | ((flagd & A8D1) == 0) && |
| 559 | ((dsize & X4) == 0)) { |
| 560 | mlib_v_ImageChannelInsert_S16_13_A8D1X4((mlib_s16 *)sp, |
| 561 | (mlib_s16 *)dp, |
| 562 | dsize, |
| 563 | ncmask); |
| 564 | } |
| 565 | else if (((flags & A8D2X4) == 0) && |
| 566 | ((flagd & A8D2X4) == 0)) { |
| 567 | mlib_v_ImageChannelInsert_S16_13_A8D2X4((mlib_s16 *)sp, strides, |
| 568 | (mlib_s16 *)dp, strided, |
| 569 | width, height, |
| 570 | ncmask); |
| 571 | } |
| 572 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 573 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 574 | mlib_v_ImageChannelInsert_S16_13_D1((mlib_s16 *)sp, |
| 575 | (mlib_s16 *)dp, |
| 576 | dsize, |
| 577 | ncmask); |
| 578 | } |
| 579 | else { |
| 580 | mlib_v_ImageChannelInsert_S16_13((mlib_s16 *)sp, strides, |
| 581 | (mlib_s16 *)dp, strided, |
| 582 | width, height, |
| 583 | ncmask); |
| 584 | } |
| 585 | break; |
| 586 | |
| 587 | case 4: |
| 588 | if (((flags & A8D1) == 0) && |
| 589 | ((flagd & A8D1) == 0) && |
| 590 | ((dsize & X4) == 0)) { |
| 591 | mlib_v_ImageChannelInsert_S16_14_A8D1X4((mlib_s16 *)sp, |
| 592 | (mlib_s16 *)dp, |
| 593 | dsize, |
| 594 | ncmask); |
| 595 | } |
| 596 | else if (((flags & A8D2X4) == 0) && |
| 597 | ((flagd & A8D2X4) == 0)) { |
| 598 | mlib_v_ImageChannelInsert_S16_14_A8D2X4((mlib_s16 *)sp, strides, |
| 599 | (mlib_s16 *)dp, strided, |
| 600 | width, height, |
| 601 | ncmask); |
| 602 | } |
| 603 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 604 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 605 | mlib_v_ImageChannelInsert_S16_14_D1((mlib_s16 *)sp, |
| 606 | (mlib_s16 *)dp, |
| 607 | dsize, |
| 608 | ncmask); |
| 609 | } |
| 610 | else { |
| 611 | mlib_v_ImageChannelInsert_S16_14((mlib_s16 *)sp, strides, |
| 612 | (mlib_s16 *)dp, strided, |
| 613 | width, height, |
| 614 | ncmask); |
| 615 | } |
| 616 | break; |
| 617 | default: |
| 618 | return MLIB_FAILURE; |
| 619 | } |
| 620 | } |
| 621 | else if ((channels == 3) && (channeld == 4) && (ncmask == 7)) { |
| 622 | if (((flags & A8D1) == 0) && |
| 623 | ((flagd & A8D1) == 0) && |
| 624 | ((dsize & X4) == 0)) { |
| 625 | mlib_v_ImageChannelInsert_S16_34R_A8D1X4((mlib_s16 *)sp, |
| 626 | (mlib_s16 *)dp, |
| 627 | dsize); |
| 628 | } |
| 629 | else if (((flags & A8D2X4) == 0) && |
| 630 | ((flagd & A8D2X4) == 0)) { |
| 631 | mlib_v_ImageChannelInsert_S16_34R_A8D2X4((mlib_s16 *)sp, strides, |
| 632 | (mlib_s16 *)dp, strided, |
| 633 | width, height); |
| 634 | } |
| 635 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 636 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 637 | mlib_v_ImageChannelInsert_S16_34R_D1((mlib_s16 *)sp, |
| 638 | (mlib_s16 *)dp, |
| 639 | dsize); |
| 640 | } |
| 641 | else { |
| 642 | mlib_v_ImageChannelInsert_S16_34R((mlib_s16 *)sp, strides, |
| 643 | (mlib_s16 *)dp, strided, |
| 644 | width, height); |
| 645 | } |
| 646 | } |
| 647 | else if ((channels == 3) && (channeld == 4) && (ncmask == 14)) { |
| 648 | if (((flags & A8D1) == 0) && |
| 649 | ((flagd & A8D1) == 0) && |
| 650 | ((dsize & X4) == 0)) { |
| 651 | mlib_v_ImageChannelInsert_S16_34L_A8D1X4((mlib_s16 *)sp, |
| 652 | (mlib_s16 *)dp, |
| 653 | dsize); |
| 654 | } |
| 655 | else if (((flags & A8D2X4) == 0) && |
| 656 | ((flagd & A8D2X4) == 0)) { |
| 657 | mlib_v_ImageChannelInsert_S16_34L_A8D2X4((mlib_s16 *)sp, strides, |
| 658 | (mlib_s16 *)dp, strided, |
| 659 | width, height); |
| 660 | } |
| 661 | else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && |
| 662 | ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { |
| 663 | mlib_v_ImageChannelInsert_S16_34L_D1((mlib_s16 *)sp, |
| 664 | (mlib_s16 *)dp, |
| 665 | dsize); |
| 666 | } |
| 667 | else { |
| 668 | mlib_v_ImageChannelInsert_S16_34L((mlib_s16 *)sp, strides, |
| 669 | (mlib_s16 *)dp, strided, |
| 670 | width, height); |
| 671 | } |
| 672 | } |
| 673 | else { |
| 674 | mlib_v_ImageChannelInsert_S16((mlib_s16 *)sp, strides, |
| 675 | (mlib_s16 *)dp, strided, |
| 676 | channels, channeld, |
| 677 | width, height, |
| 678 | ncmask); |
| 679 | } |
| 680 | break; |
| 681 | |
| 682 | case MLIB_INT: |
| 683 | mlib_v_ImageChannelInsert_S32((mlib_s32 *)sp, strides, |
| 684 | (mlib_s32 *)dp, strided, |
| 685 | channels, channeld, |
| 686 | width, height, |
| 687 | ncmask); |
| 688 | break; |
| 689 | |
| 690 | case MLIB_FLOAT: |
| 691 | mlib_v_ImageChannelInsert_S32((mlib_s32 *)sp, strides, |
| 692 | (mlib_s32 *)dp, strided, |
| 693 | channels, channeld, |
| 694 | width, height, |
| 695 | ncmask); |
| 696 | break; |
| 697 | |
| 698 | |
| 699 | case MLIB_DOUBLE: |
| 700 | mlib_v_ImageChannelInsert_D64((mlib_d64 *)sp, strides, |
| 701 | (mlib_d64 *)dp, strided, |
| 702 | channels, channeld, |
| 703 | width, height, |
| 704 | ncmask); |
| 705 | break; |
| 706 | |
| 707 | |
| 708 | case MLIB_BIT: |
| 709 | default: |
| 710 | return MLIB_FAILURE; /* MLIB_BIT is not supported here */ |
| 711 | } |
| 712 | |
| 713 | return MLIB_SUCCESS; |
| 714 | } |
| 715 | /***************************************************************/ |