/*
* 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.
*/
/*
* FUNCTION
* mlib_ImageZoom - image scaling with edge condition
*
* SYNOPSIS
* mlib_status mlib_ImageZoom(mlib_image *dst,
* const mlib_image *src,
* mlib_f32 zoomx,
* mlib_f32 zoomy,
* mlib_filter filter,
* mlib_edge edge)
*
* ARGUMENTS
* dst Pointer to destination image
* src Pointer to source image
* zoomx X zoom factor.
* zoomy Y zoom factor.
* filter Type of resampling filter.
* edge Type of edge condition.
*
* DESCRIPTION
* The center of the source image is mapped to the center of the
* destination image.
*
* The upper-left corner pixel of an image is located at (0.5, 0.5).
*
* The resampling filter can be one of the following:
* MLIB_NEAREST
* MLIB_BILINEAR
* MLIB_BICUBIC
* MLIB_BICUBIC2
*
* The edge condition can be one of the following:
* MLIB_EDGE_DST_NO_WRITE (default)
* MLIB_EDGE_DST_FILL_ZERO
* MLIB_EDGE_OP_NEAREST
* MLIB_EDGE_SRC_EXTEND
* MLIB_EDGE_SRC_PADDED
*/
#ifdef MACOSX
#endif
#include <mlib_image.h>
#include <mlib_ImageZoom.h>
/***************************************************************/
#ifdef i386 /* do not perform the coping by mlib_d64 data type for x86 */
typedef struct {
} two_int;
#else /* i386 ( do not perform the coping by mlib_d64 data type for x86 ) */
#endif /* i386 ( do not perform the coping by mlib_d64 data type for x86 ) */
/***************************************************************/
typedef union {
struct {
} f32s;
} d64_2_f32;
/***************************************************************/
/***************************************************************/
#ifdef _LITTLE_ENDIAN
0x00000000u, 0xFF000000u, 0x00FF0000u, 0xFFFF0000u,
0x0000FF00u, 0xFF00FF00u, 0x00FFFF00u, 0xFFFFFF00u,
0x000000FFu, 0xFF0000FFu, 0x00FF00FFu, 0xFFFF00FFu,
0x0000FFFFu, 0xFF00FFFFu, 0x00FFFFFFu, 0xFFFFFFFFu
};
#else /* _LITTLE_ENDIAN */
0x00000000u, 0x000000FFu, 0x0000FF00u, 0x0000FFFFu,
0x00FF0000u, 0x00FF00FFu, 0x00FFFF00u, 0x00FFFFFFu,
0xFF000000u, 0xFF0000FFu, 0xFF00FF00u, 0xFF00FFFFu,
0xFFFF0000u, 0xFFFF00FFu, 0xFFFFFF00u, 0xFFFFFFFFu
};
#endif /* _LITTLE_ENDIAN */
/***************************************************************/
mlib_s32 j, \
/***************************************************************/
/***************************************************************/
{
mlib_s32 i;
num0 &= 7;
return MLIB_FAILURE;
}
/* save shifts for bit extracting */
#if 0
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < (n_al >> 3); i++) {
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
}
x_last = x;
#else /* 0 */
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < (n_al >> 3); i++) {
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
}
#endif /* 0 */
for (j = 0; j < height; j++) {
if (!y_step) {
if (num0) {
dp++;
}
#if 0
if (n_al & 7) {
}
#else /* 0 */
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < (n_al >> 3); i++) {
}
if (n_al & 7) {
}
#endif /* 0 */
}
else {
x = srcX;
if (num0) {
res |=
x += dx;
}
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < (n_al >> 3); i++) {
#if 0
#else /* 0 */
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
#endif /* 0 */
}
if (mask1) {
for (k = 0; k < (n_al & 7); k++) {
res |=
x += dx;
}
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
#ifdef _NO_LONGLONG
typedef struct {
#ifdef _LITTLE_ENDIAN
#else /* _LITTLE_ENDIAN */
#endif /* _LITTLE_ENDIAN */
} two_uint;
/***************************************************************/
/***************************************************************/
if ((rshift) >= 32) { \
} \
else { \
} \
}
/***************************************************************/
if ((lshift) >= 32) { \
} \
else { \
} \
}
/***************************************************************/
}
#else /* _NO_LONGLONG */
/***************************************************************/
#endif /* _NO_LONGLONG */
/***************************************************************/
{
mlib_s32 i;
mlib_s32 k;
return MLIB_FAILURE;
}
/* save shifts for bit extracting */
x = srcX;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width8; i++) {
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
}
/* calculate lookup table */
for (i = 0; i < 16; i++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (j = 0; j < 16; j++) {
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (j = 0; j < 16; j++) {
}
}
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
x = srcX;
if (off) { /* not aligned */
off *= 8;
#ifdef _LITTLE_ENDIAN
#else /* _LITTLE_ENDIAN */
#endif /* _LITTLE_ENDIAN */
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < (width / 8); i++) {
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
#ifdef _LITTLE_ENDIAN
/* *da++ = (dd_old >> (64 - off)) | (dd << off);*/
#else /* _LITTLE_ENDIAN */
/* *da++ = (dd_old << (64 - off)) | (dd >> off);*/
#endif /* _LITTLE_ENDIAN */
}
#ifdef _LITTLE_ENDIAN
/* da[0] = (dd_old >> (64 - off)) | (da[0] & ((mlib_u64)((mlib_s64) -1) << off));*/
#else /* _LITTLE_ENDIAN */
/* da[0] = (dd_old << (64 - off)) | (da[0] & ((mlib_u64)((mlib_s64) -1) >> off));*/
#endif /* _LITTLE_ENDIAN */
}
else { /* aligned */
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < (width / 8); i++) {
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
x += dx;
}
}
if (width & 7) {
for (k = 0; k < (width & 7); k++) {
dp[k] =
x += dx;
}
}
}
y += dy;
dl += dst_stride;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
x += dx;
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
tdp += 4;
}
}
else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
tdp += 4;
}
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
x += dx;
}
}
else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
x += dx;
}
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
tdp += 8;
}
}
else { /* align to word */
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
tdp += 8;
}
}
}
else { /* align to mlib_d64 word */
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
tdp += 8;
}
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
x += dx;
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
x += dx;
x += dx;
}
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width; i++) {
x += dx;
}
}
else {
x += dx;
x += dx;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
x += dx;
x += dx;
}
if (width & 1) {
}
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
x += dx;
x += dx;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
if (!y_step) {
}
else {
x += dx;
x += dx;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
}
}
else {
x += dx;
x += dx;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
}
}
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width; i++) {
cx = x >> MLIB_SHIFT;
x += dx;
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width; i++) {
x += dx;
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
x += dx;
x += dx;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
mlib_s32 i;
for (j = 0; j < height; j++) {
x += dx;
x += dx;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < width - 1; i++) {
x += dx;
}
y += dy;
}
return MLIB_SUCCESS;
}
/***************************************************************/