/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* FUNCTIONS
* mlib_ImageCopy_bit_na - BIT, non-aligned
* mlib_ImageCopy_bit_na_r - BIT, non-aligned, reverse
*
* SYNOPSIS
*
* void mlib_ImageCopy_bit_na(const mlib_u8 *sa,
* mlib_u8 *da,
* mlib_s32 size,
* mlib_s32 s_offset,
* mlib_s32 d_offset);
* void mlib_ImageCopy_bit_na_r(const mlib_u8 *sa,
* mlib_u8 *da,
* mlib_s32 size,
* mlib_s32 s_offset,
* mlib_s32 d_offset);
* ARGUMENT
* sp pointer to source image data
* dp pointer to destination image data
* size size in 8-bytes, bytes, or SHORTs
* width image width in 8-bytes
* height image height in lines
* stride source image line stride in 8-bytes
* dstride destination image line stride in 8-bytes
* s_offset source image line bit offset
* d_offset destination image line bit offset
*
* DESCRIPTION
* Direct copy from one image to another -- C version low level
* functions.
*/
#include <stdlib.h>
#include "mlib_image.h"
#include "mlib_ImageCopy.h"
/***************************************************************/
/*
* Bit offsets of source and distination are not the same
*/
{
#ifdef _NO_LONGLONG
mlib_s32 j; /* offset of address in dst */
if (size <= 0) return;
/* prepare the destination addresses */
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
return;
}
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
j = 32 - ld_offset;
dp++;
ls_offset += j;
} else {
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
return;
}
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
j = 32 - ld_offset;
dp++;
sp++;
}
#ifdef _LITTLE_ENDIAN
#endif /* _LITTLE_ENDIAN */
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
sp++;
dp++;
}
if (j < size) {
j = size - j;
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
}
#else /* _LONGLONG */
mlib_s32 j; /* offset of address in dst */
if (size <= 0) return;
/* prepare the destination addresses */
/* we can explicitly cast ro mlib_s32 here because value is in [0,64] range */
ld_offset = (((mlib_s32) ((mlib_addr)da & 7)) << 3) + d_offset; /* bit d_offset to first mlib_d64 */
ls_offset = (((mlib_s32) ((mlib_addr)sa & 7)) << 3) + s_offset; /* bit d_offset to first mlib_d64 */
return;
}
j = 64 - ld_offset;
dp++;
ls_offset += j;
} else {
return;
}
j = 64 - ld_offset;
dp++;
sp++;
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
sp++;
dp++;
}
if (j < size) {
j = size - j;
}
#endif /* _NO_LONGLONG */
}
/***************************************************************/
/*
* Bit offsets of source and distination are not the same
* This function is both for C and VIS version (LONGLONG case)
*/
{
#ifdef _NO_LONGLONG
mlib_s32 j; /* offset of address in dst */
if (size <= 0) return;
/* prepare the destination addresses */
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
return;
}
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
j = ld_offset;
dp--;
ls_offset -= j;
} else {
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
return;
}
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
j = ld_offset;
dp--;
sp--;
}
#ifdef _LITTLE_ENDIAN
#endif /* _LITTLE_ENDIAN */
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
sp--;
dp--;
}
if (j < size) {
j = size - j;
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
}
#else /* _LONGLONG */
mlib_s32 j; /* offset of address in dst */
if (size <= 0) return;
/* prepare the destination addresses */
/* we can explicitly cast ro mlib_s32 here because value is in [0,64] range */
ld_offset = (((mlib_s32) ((mlib_addr)da & 7)) << 3) + d_offset; /* bit d_offset to first mlib_d64 */
ls_offset = (((mlib_s32) ((mlib_addr)sa & 7)) << 3) + s_offset; /* bit d_offset to first mlib_d64 */
return;
}
j = ld_offset;
dp--;
ls_offset -= j;
} else {
return;
}
j = ld_offset;
dp--;
sp--;
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
sp--;
dp--;
}
if (j < size) {
j = size - j;
}
#endif /* _NO_LONGLONG */
}
/***************************************************************/