0N/A/*
2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A
0N/A/*
0N/A * FUNCTIONS
0N/A * mlib_ImageCopy - Direct copy from one image to another.
0N/A *
0N/A * SYNOPSIS
0N/A * mlib_status mlib_ImageCopy(mlib_image *dst,
0N/A * const mlib_image *src);
0N/A *
0N/A * ARGUMENT
0N/A * dst pointer to output or destination image
0N/A * src pointer to input or source image
0N/A *
0N/A * RESTRICTION
0N/A * src and dst must have the same size, type and number of channels.
0N/A * They can have 1, 2, 3 or 4 channels of MLIB_BIT, MLIB_BYTE, MLIB_SHORT,
0N/A * MLIB_USHORT, MLIB_INT, MLIB_FLOAT or MLIB_DOUBLE data type.
0N/A *
0N/A * DESCRIPTION
0N/A * Direct copy from one image to another
0N/A */
0N/A
0N/A#include <stdlib.h>
0N/A#include "mlib_image.h"
0N/A#include "mlib_ImageCheck.h"
0N/A#include "mlib_ImageCopy.h"
0N/A
0N/A/***************************************************************/
0N/A#ifdef _MSC_VER
0N/A#pragma optimize("", off) /* Fix bug 4195132 */
0N/A#endif /* _MSC_VER */
0N/A
0N/A/***************************************************************/
0N/A/* do not perform the coping by mlib_d64 data type for x86 */
0N/A#ifdef i386
0N/A
0N/Atypedef struct {
0N/A mlib_s32 int0, int1;
0N/A} two_int;
0N/A
0N/A#define TYPE_64BIT two_int
0N/A
0N/A#else /* i386 */
0N/A
0N/A#define TYPE_64BIT mlib_d64
0N/A#endif /* i386 */
0N/A
0N/A/***************************************************************/
0N/Astatic void mlib_c_ImageCopy_u8(const mlib_image *src,
0N/A mlib_image *dst);
0N/Astatic void mlib_c_ImageCopy_s16(const mlib_image *src,
0N/A mlib_image *dst);
0N/Astatic void mlib_c_ImageCopy_s32(const mlib_image *src,
0N/A mlib_image *dst);
0N/Astatic void mlib_c_ImageCopy_d64(const mlib_image *src,
0N/A mlib_image *dst);
0N/Astatic void mlib_c_ImageCopy_a1(const TYPE_64BIT *sp,
0N/A TYPE_64BIT *dp,
0N/A mlib_s32 size);
0N/A
0N/A/***************************************************************/
0N/Amlib_status mlib_ImageCopy(mlib_image *dst,
0N/A const mlib_image *src)
0N/A{
0N/A mlib_s32 s_offset, d_offset;
0N/A mlib_s32 size, s_stride, d_stride;
0N/A mlib_s32 width; /* width in bytes of src and dst */
0N/A mlib_s32 height; /* height in lines of src and dst */
0N/A mlib_u8 *sa, *da;
0N/A mlib_s32 j;
0N/A
0N/A MLIB_IMAGE_CHECK(src);
0N/A MLIB_IMAGE_CHECK(dst);
0N/A MLIB_IMAGE_TYPE_EQUAL(src, dst);
0N/A MLIB_IMAGE_CHAN_EQUAL(src, dst);
0N/A MLIB_IMAGE_SIZE_EQUAL(src, dst);
0N/A
0N/A switch (mlib_ImageGetType(dst)) {
0N/A case MLIB_BIT:
0N/A width = mlib_ImageGetWidth(dst) * mlib_ImageGetChannels(dst); /* size in bits */
0N/A height = mlib_ImageGetHeight(src);
0N/A sa = (mlib_u8 *) mlib_ImageGetData(src);
0N/A da = (mlib_u8 *) mlib_ImageGetData(dst);
0N/A
0N/A if (!mlib_ImageIsNotOneDvector(src) && !mlib_ImageIsNotOneDvector(dst)) {
0N/A size = height * (width >> 3);
0N/A if (!mlib_ImageIsNotAligned8(src) && !mlib_ImageIsNotAligned8(dst) && ((size & 7) == 0)) {
0N/A
0N/A mlib_c_ImageCopy_a1((TYPE_64BIT *) sa, (TYPE_64BIT *) da, size >> 3);
0N/A }
0N/A else {
0N/A
0N/A mlib_ImageCopy_na(sa, da, size);
0N/A }
0N/A }
0N/A else {
0N/A s_stride = mlib_ImageGetStride(src);
0N/A d_stride = mlib_ImageGetStride(dst);
0N/A s_offset = mlib_ImageGetBitOffset(src); /* in bits */
0N/A d_offset = mlib_ImageGetBitOffset(dst); /* in bits */
0N/A if (s_offset == d_offset) {
0N/A for (j = 0; j < height; j++) {
0N/A mlib_ImageCopy_bit_al(sa, da, width, s_offset);
0N/A sa += s_stride;
0N/A da += d_stride;
0N/A }
0N/A }
0N/A else {
0N/A for (j = 0; j < height; j++) {
0N/A mlib_ImageCopy_bit_na(sa, da, width, s_offset, d_offset);
0N/A sa += s_stride;
0N/A da += d_stride;
0N/A }
0N/A }
0N/A }
0N/A
0N/A break;
0N/A case MLIB_BYTE:
0N/A mlib_c_ImageCopy_u8(src, dst);
0N/A break;
0N/A case MLIB_SHORT:
0N/A case MLIB_USHORT:
0N/A mlib_c_ImageCopy_s16(src, dst);
0N/A break;
0N/A case MLIB_INT:
0N/A case MLIB_FLOAT:
0N/A mlib_c_ImageCopy_s32(src, dst);
0N/A break;
0N/A case MLIB_DOUBLE:
0N/A mlib_c_ImageCopy_d64(src, dst);
0N/A break;
0N/A default:
0N/A return MLIB_FAILURE; /* MLIB_BIT is not supported here */
0N/A }
0N/A
0N/A return MLIB_SUCCESS;
0N/A}
0N/A
0N/A/***************************************************************/
0N/A#define PREPAREVARS(type) \
0N/A type *psrc = (type *) mlib_ImageGetData(src); \
0N/A type *pdst = (type *) mlib_ImageGetData(dst); \
0N/A mlib_s32 src_height = mlib_ImageGetHeight(src); \
0N/A mlib_s32 src_width = mlib_ImageGetWidth(src); \
0N/A mlib_s32 src_stride = mlib_ImageGetStride(src) / sizeof(type); \
0N/A mlib_s32 dst_stride = mlib_ImageGetStride(dst) / sizeof(type); \
0N/A mlib_s32 chan = mlib_ImageGetChannels(dst); \
0N/A mlib_s32 i, j; \
0N/A \
0N/A src_width *= chan; \
0N/A if (src_width == src_stride && src_width == dst_stride) { \
0N/A src_width *= src_height; \
0N/A src_height = 1; \
0N/A }
0N/A
0N/A/***************************************************************/
0N/A#define STRIP(pd, ps, w, h, data_type) { \
0N/A data_type s0, s1; \
0N/A for ( i = 0; i < h; i++ ) { \
0N/A if (j = w & 1) \
0N/A pd[i * dst_stride] = ps[i * src_stride]; \
0N/A for (; j < w; j += 2) { \
0N/A s0 = ps[i * src_stride + j]; \
0N/A s1 = ps[i * src_stride + j + 1]; \
0N/A pd[i * dst_stride + j] = s0; \
0N/A pd[i * dst_stride + j + 1] = s1; \
0N/A } \
0N/A } \
0N/A}
0N/A
0N/A/***************************************************************/
0N/A/*
0N/A * Both bit offsets of source and distination are the same
0N/A */
0N/A
0N/Avoid mlib_ImageCopy_bit_al(const mlib_u8 *sa,
0N/A mlib_u8 *da,
0N/A mlib_s32 size,
0N/A mlib_s32 offset)
0N/A{
0N/A mlib_s32 b_size, i, j;
0N/A TYPE_64BIT *sp, *dp;
0N/A mlib_u8 mask0 = 0xFF;
0N/A mlib_u8 src, mask;
0N/A
0N/A if (size <= 0) return;
0N/A
0N/A if (size <= (8 - offset)) {
0N/A mask = mask0 << (8 - size);
0N/A mask >>= offset;
0N/A src = da[0];
0N/A da[0] = (src & (~mask)) | (sa[0] & mask);
0N/A return;
0N/A }
0N/A
0N/A mask = mask0 >> offset;
0N/A src = da[0];
0N/A da[0] = (src & (~mask)) | (sa[0] & mask);
0N/A da++;
0N/A sa++;
0N/A size = size - 8 + offset;
0N/A b_size = size >> 3; /* size in bytes */
0N/A
0N/A for (j = 0; (j < b_size) && (((mlib_addr) da & 7) != 0); j++)
0N/A *da++ = *sa++;
0N/A
0N/A if ((((mlib_addr) sa ^ (mlib_addr) da) & 7) == 0) {
0N/A sp = (TYPE_64BIT *) sa;
0N/A dp = (TYPE_64BIT *) da;
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (i = 0; j <= (b_size - 8); j += 8, i++) {
0N/A dp[i] = sp[i];
0N/A }
0N/A
0N/A sa += i << 3;
0N/A da += i << 3;
0N/A }
0N/A else {
0N/A#ifdef _NO_LONGLONG
0N/A if ((((mlib_addr) sa ^ (mlib_addr) da) & 3) == 0) {
0N/A mlib_u32 *pws, *pwd;
0N/A
0N/A pws = (mlib_u32 *) sa;
0N/A pwd = (mlib_u32 *) da;
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (i = 0; j <= (b_size - 4); j += 4, i++) {
0N/A pwd[i] = pws[i];
0N/A }
0N/A
0N/A sa += i << 2;
0N/A da += i << 2;
0N/A }
0N/A else {
0N/A mlib_u32 *pws, *pwd, src0, src1;
0N/A mlib_s32 lshift = (mlib_addr) sa & 3, rshift;
0N/A
0N/A pwd = (mlib_u32 *) da;
0N/A pws = (mlib_u32 *) (sa - lshift);
0N/A lshift <<= 3;
0N/A rshift = 32 - lshift;
0N/A
0N/A src1 = pws[0];
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (i = 0; j <= (b_size - 4); j += 4, i++) {
0N/A src0 = src1;
0N/A src1 = pws[i + 1];
0N/A#ifdef _LITTLE_ENDIAN
0N/A pwd[i] = (src0 >> lshift) | (src1 << rshift);
0N/A#else
0N/A pwd[i] = (src0 << lshift) | (src1 >> rshift);
0N/A#endif /* _LITTLE_ENDIAN */
0N/A }
0N/A
0N/A sa += i << 2;
0N/A da += i << 2;
0N/A }
0N/A
0N/A#else
0N/A mlib_u64 *pws, *pwd, src0, src1;
0N/A mlib_s32 lshift = (mlib_s32) ((mlib_addr) sa & 7), rshift;
0N/A
0N/A pwd = (mlib_u64 *) da;
0N/A pws = (mlib_u64 *) (sa - lshift);
0N/A lshift <<= 3;
0N/A rshift = 64 - lshift;
0N/A
0N/A src1 = pws[0];
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (i = 0; j <= (b_size - 8); j += 8, i++) {
0N/A src0 = src1;
0N/A src1 = pws[i + 1];
0N/A pwd[i] = (src0 << lshift) | (src1 >> rshift);
0N/A }
0N/A
0N/A sa += i << 3;
0N/A da += i << 3;
0N/A#endif /* _NO_LONGLONG */
0N/A }
0N/A
0N/A for (; j < b_size; j++)
0N/A *da++ = *sa++;
0N/A
0N/A j = size & 7;
0N/A
0N/A if (j > 0) {
0N/A mask = mask0 << (8 - j);
0N/A src = da[0];
0N/A da[0] = (src & (~mask)) | (sa[0] & mask);
0N/A }
0N/A}
0N/A
0N/A/***************************************************************/
0N/Avoid mlib_c_ImageCopy_u8(const mlib_image *src,
0N/A mlib_image *dst)
0N/A{
0N/A PREPAREVARS(mlib_u8);
0N/A if (src_width < 16) {
0N/A STRIP(pdst, psrc, src_width, src_height, mlib_u8);
0N/A return;
0N/A }
0N/A
0N/A for (i = 0; i < src_height; i++) {
0N/A mlib_u8 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
0N/A
0N/A if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
0N/A for (j = 0; j < (mlib_s32) ((8 - (mlib_addr) psrc_row) & 7); j++) {
0N/A pdst_row[j] = psrc_row[j];
0N/A }
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 8); j += 8) {
0N/A TYPE_64BIT dsrc0 = *((TYPE_64BIT *) (psrc_row + j));
0N/A
0N/A *((TYPE_64BIT *) (pdst_row + j)) = dsrc0;
0N/A }
0N/A }
0N/A else {
0N/A
0N/A#ifdef _NO_LONGLONG
0N/A
0N/A for (j = 0; j < (mlib_s32) ((4 - (mlib_addr) pdst_row) & 3); j++) {
0N/A pdst_row[j] = psrc_row[j];
0N/A }
0N/A
0N/A if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 3)) {
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 4); j += 4) {
0N/A *((mlib_s32 *) (pdst_row + j)) = *((mlib_s32 *) (psrc_row + j));
0N/A }
0N/A }
0N/A else {
0N/A mlib_u32 *ps, shl, shr, src0, src1;
0N/A
0N/A ps = (mlib_u32 *) (psrc_row + j);
0N/A shl = (mlib_addr) ps & 3;
0N/A ps = (mlib_u32 *) ((mlib_addr) ps - shl);
0N/A shl <<= 3;
0N/A shr = 32 - shl;
0N/A
0N/A src1 = ps[0];
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 4); j += 4) {
0N/A src0 = src1;
0N/A src1 = ps[1];
0N/A#ifdef _LITTLE_ENDIAN
0N/A *((mlib_s32 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
0N/A#else
0N/A *((mlib_s32 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
0N/A#endif /* _LITTLE_ENDIAN */
0N/A ps++;
0N/A }
0N/A }
0N/A
0N/A#else
0N/A
0N/A for (j = 0; j < (mlib_s32) ((8 - (mlib_addr) pdst_row) & 7); j++) {
0N/A pdst_row[j] = psrc_row[j];
0N/A }
0N/A
0N/A {
0N/A mlib_s32 shl, shr;
0N/A mlib_u64 *ps, src0, src1;
0N/A
0N/A ps = (mlib_u64 *) (psrc_row + j);
0N/A /* shl and shr are in range [0, 64] */
0N/A shl = (mlib_s32) ((mlib_addr) ps & 7);
0N/A ps = (mlib_u64 *) ((mlib_addr) ps - shl);
0N/A shl <<= 3;
0N/A shr = 64 - shl;
0N/A
0N/A src1 = ps[0];
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 8); j += 8) {
0N/A src0 = src1;
0N/A src1 = ps[1];
0N/A#ifdef _LITTLE_ENDIAN
0N/A *((mlib_s64 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
0N/A#else
0N/A *((mlib_s64 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
0N/A#endif /* _LITTLE_ENDIAN */
0N/A ps++;
0N/A }
0N/A }
0N/A#endif /* _NO_LONGLONG */
0N/A }
0N/A
0N/A for (; j < src_width; j++)
0N/A pdst_row[j] = psrc_row[j];
0N/A }
0N/A}
0N/A
0N/A/***************************************************************/
0N/Avoid mlib_c_ImageCopy_s16(const mlib_image *src,
0N/A mlib_image *dst)
0N/A{
0N/A PREPAREVARS(mlib_u16);
0N/A if (src_width < 8) {
0N/A STRIP(pdst, psrc, src_width, src_height, mlib_u16);
0N/A return;
0N/A }
0N/A
0N/A for (i = 0; i < src_height; i++) {
0N/A mlib_u16 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
0N/A
0N/A if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
0N/A for (j = 0; j < (mlib_s32) (((8 - (mlib_addr) psrc_row) & 7) >> 1); j++) {
0N/A pdst_row[j] = psrc_row[j];
0N/A }
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 4); j += 4) {
0N/A TYPE_64BIT dsrc0 = *((TYPE_64BIT *) (psrc_row + j));
0N/A
0N/A *((TYPE_64BIT *) (pdst_row + j)) = dsrc0;
0N/A }
0N/A }
0N/A else {
0N/A
0N/A#ifdef _NO_LONGLONG
0N/A
0N/A if (j = (((mlib_addr) pdst_row & 2) != 0)) {
0N/A pdst_row[0] = psrc_row[0];
0N/A }
0N/A
0N/A if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 3)) {
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 2); j += 2) {
0N/A *((mlib_s32 *) (pdst_row + j)) = *((mlib_s32 *) (psrc_row + j));
0N/A }
0N/A }
0N/A else {
0N/A mlib_u32 *ps, src0, src1;
0N/A
0N/A ps = (mlib_u32 *) (psrc_row + j - 1);
0N/A src1 = ps[0];
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 2); j += 2) {
0N/A src0 = src1;
0N/A src1 = ps[1];
0N/A#ifdef _LITTLE_ENDIAN
0N/A *((mlib_s32 *) (pdst_row + j)) = (src0 >> 16) | (src1 << 16);
0N/A#else
0N/A *((mlib_s32 *) (pdst_row + j)) = (src0 << 16) | (src1 >> 16);
0N/A#endif /* _LITTLE_ENDIAN */
0N/A ps++;
0N/A }
0N/A }
0N/A
0N/A#else
0N/A
0N/A for (j = 0; j < (mlib_s32) (((8 - (mlib_addr) pdst_row) & 7) >> 1); j++) {
0N/A pdst_row[j] = psrc_row[j];
0N/A }
0N/A
0N/A {
0N/A mlib_s32 shl, shr;
0N/A mlib_u64 *ps, src0, src1;
0N/A
0N/A ps = (mlib_u64 *) (psrc_row + j);
0N/A shl = (mlib_s32) ((mlib_addr) ps & 7);
0N/A ps = (mlib_u64 *) ((mlib_addr) ps - shl);
0N/A shl <<= 3;
0N/A shr = 64 - shl;
0N/A
0N/A src1 = ps[0];
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 4); j += 4) {
0N/A src0 = src1;
0N/A src1 = ps[1];
0N/A#ifdef _LITTLE_ENDIAN
0N/A *((mlib_s64 *) (pdst_row + j)) = (src0 >> shl) | (src1 << shr);
0N/A#else
0N/A *((mlib_s64 *) (pdst_row + j)) = (src0 << shl) | (src1 >> shr);
0N/A#endif /* _LITTLE_ENDIAN */
0N/A ps++;
0N/A }
0N/A }
0N/A#endif /* _NO_LONGLONG */
0N/A }
0N/A
0N/A for (; j < src_width; j++)
0N/A pdst_row[j] = psrc_row[j];
0N/A }
0N/A}
0N/A
0N/A/***************************************************************/
0N/Avoid mlib_c_ImageCopy_s32(const mlib_image *src,
0N/A mlib_image *dst)
0N/A{
0N/A PREPAREVARS(mlib_u32);
0N/A if (src_width < 4) {
0N/A STRIP(pdst, psrc, src_width, src_height, mlib_u32);
0N/A return;
0N/A }
0N/A
0N/A for (i = 0; i < src_height; i++) {
0N/A mlib_u32 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
0N/A
0N/A if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
0N/A if (j = ((mlib_s32) ((mlib_addr) psrc_row & 4) >> 2)) {
0N/A pdst_row[0] = psrc_row[0];
0N/A }
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 2); j += 2) {
0N/A TYPE_64BIT dsrc0 = *((TYPE_64BIT *) (psrc_row + j));
0N/A
0N/A *((TYPE_64BIT *) (pdst_row + j)) = dsrc0;
0N/A }
0N/A }
0N/A else {
0N/A
0N/A#ifdef _NO_LONGLONG
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (j = 0; j <= (src_width - 1); j++) {
0N/A *((mlib_s32 *) (pdst_row + j)) = *((mlib_s32 *) (psrc_row + j));
0N/A }
0N/A
0N/A#else
0N/A
0N/A {
0N/A mlib_u64 *ps, src0, src1;
0N/A
0N/A if (j = ((mlib_s32) ((mlib_addr) pdst_row & 4) >> 2))
0N/A pdst_row[0] = psrc_row[0];
0N/A ps = (mlib_u64 *) (psrc_row + j - 1);
0N/A src1 = ps[0];
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; j <= (src_width - 2); j += 2) {
0N/A src0 = src1;
0N/A src1 = ps[1];
0N/A#ifdef _LITTLE_ENDIAN
0N/A *((mlib_s64 *) (pdst_row + j)) = (src0 >> 32) | (src1 << 32);
0N/A#else
0N/A *((mlib_s64 *) (pdst_row + j)) = (src0 << 32) | (src1 >> 32);
0N/A#endif /* _LITTLE_ENDIAN */
0N/A ps++;
0N/A }
0N/A }
0N/A#endif /* _NO_LONGLONG */
0N/A }
0N/A
0N/A for (; j < src_width; j++)
0N/A pdst_row[j] = psrc_row[j];
0N/A }
0N/A}
0N/A
0N/A/***************************************************************/
0N/Avoid mlib_c_ImageCopy_d64(const mlib_image *src,
0N/A mlib_image *dst)
0N/A{
0N/A PREPAREVARS(mlib_d64);
0N/A for (i = 0; i < src_height; i++) {
0N/A mlib_d64 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (j = 0; j < src_width; j++)
0N/A *((mlib_d64 *) (pdst_row + j)) = *((mlib_d64 *) (psrc_row + j));
0N/A }
0N/A}
0N/A
0N/A/***************************************************************/
0N/A/*
0N/A * Both source and destination image data are 1 - d vectors and
0N/A * 8 - byte aligned. And size is in 8 - bytes.
0N/A */
0N/A
0N/Avoid mlib_c_ImageCopy_a1(const TYPE_64BIT *sp,
0N/A TYPE_64BIT *dp,
0N/A mlib_s32 size)
0N/A{
0N/A mlib_s32 i;
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (i = 0; i < size; i++) {
0N/A *dp++ = *sp++;
0N/A }
0N/A}
0N/A
0N/A/***************************************************************/
0N/A#ifndef _NO_LONGLONG
0N/A#define TYPE mlib_u64
0N/A#define BSIZE 64
0N/A#define SIZE 8
0N/A#else
0N/A#define TYPE mlib_u32
0N/A#define BSIZE 32
0N/A#define SIZE 4
0N/A#endif /* _NO_LONGLONG */
0N/A
0N/A/***************************************************************/
0N/Avoid mlib_ImageCopy_na(const mlib_u8 *sp,
0N/A mlib_u8 *dp,
0N/A mlib_s32 n)
0N/A{
0N/A mlib_s32 shr, shl;
0N/A TYPE *tmp, s0, s1;
0N/A
0N/A if (((mlib_addr) sp ^ (mlib_addr) dp) & 7) {
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; (n > 0) && (mlib_addr) dp & (SIZE - 1); n--)
0N/A *dp++ = *sp++;
0N/A
0N/A#ifdef _NO_LONGLONG
0N/A
0N/A if (((mlib_addr) sp & (SIZE - 1)) == 0) {
0N/A for (; n > SIZE; n -= SIZE) {
0N/A *(TYPE *) dp = *(TYPE *) sp;
0N/A dp += SIZE;
0N/A sp += SIZE;
0N/A }
0N/A }
0N/A else
0N/A#endif /* _NO_LONGLONG */
0N/A {
0N/A tmp = (TYPE *) ((mlib_addr) sp & ~(SIZE - 1));
0N/A /* shl and shr do not exceed 64 here */
0N/A shl = (mlib_s32) (((mlib_addr) sp & (SIZE - 1)) << 3);
0N/A shr = BSIZE - shl;
0N/A s0 = *tmp++;
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; n > SIZE; n -= SIZE) {
0N/A s1 = *tmp++;
0N/A#ifdef _LITTLE_ENDIAN
0N/A *(TYPE *) dp = (s0 >> shl) | (s1 << shr);
0N/A#else
0N/A *(TYPE *) dp = (s0 << shl) | (s1 >> shr);
0N/A#endif /* _LITTLE_ENDIAN */
0N/A s0 = s1;
0N/A dp += SIZE;
0N/A sp += SIZE;
0N/A }
0N/A }
0N/A }
0N/A else {
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; (n > 0) && (mlib_addr) dp & 7; n--)
0N/A *dp++ = *sp++;
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; n > 8; n -= 8) {
0N/A *(TYPE_64BIT *) dp = *(TYPE_64BIT *) sp;
0N/A dp += 8;
0N/A sp += 8;
0N/A }
0N/A }
0N/A
0N/A#ifdef __SUNPRO_C
0N/A#pragma pipeloop(0)
0N/A#endif /* __SUNPRO_C */
0N/A for (; n > 0; n--)
0N/A *dp++ = *sp++;
0N/A}
0N/A
0N/A/***************************************************************/
0N/A#ifdef _MSC_VER
0N/A#pragma optimize("", on)
0N/A#endif /* _MSC_VER */
0N/A
0N/A/***************************************************************/