/*
* 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_EDGE_SRC_EXTEND mask
*/
#include "mlib_image.h"
#include "mlib_ImageConv.h"
#include "mlib_c_ImageConv.h"
/*
* This define switches between functions of different data types
*/
/***************************************************************/
#if IMG_TYPE == 1
#define S64TOS32(x) (x)
#define SAT_OFF
#define S64TOS32(x) (x)
#endif /* IMG_TYPE == 1 */
/***************************************************************/
/***************************************************************/
#define PARAM \
mlib_image *dst, \
const mlib_image *src, \
/***************************************************************/
#define PARAM_MxN \
mlib_image *dst, \
const mlib_image *src, \
mlib_s32 m, \
mlib_s32 n, \
/***************************************************************/
#ifndef MLIB_USE_FTOI_CLAMPING
#define CLAMP_S32(x) \
#else
#endif /* MLIB_USE_FTOI_CLAMPING */
/***************************************************************/
/***************************************************************/
#ifdef _LITTLE_ENDIAN
#else
#endif /* _LITTLE_ENDIAN */
/***************************************************************/
#ifdef _NO_LONGLONG
#else /* _NO_LONGLONG */
#ifdef _LITTLE_ENDIAN
#else /* _LITTLE_ENDIAN */
#endif /* _LITTLE_ENDIAN */
#endif /* _NO_LONGLONG */
/***************************************************************/
/***************************************************************/
typedef union {
struct {
} i32s;
} d64_2x32;
/***************************************************************/
/***************************************************************/
/***************************************************************/
#define LOAD_KERNEL3() \
\
while (scalef_expon > 30) { \
scalef_expon -= 30; \
} \
\
\
/* keep kernel in regs */ \
/***************************************************************/
\
while (scalef_expon > 30) { \
scalef_expon -= 30; \
} \
\
\
/***************************************************************/
/***************************************************************/
#ifndef __sparc
#if IMG_TYPE == 1
/*
* Test for the presence of any "1" bit in bits
8 to 31 of val. If present, then val is either
negative or >255. If over/underflows of 8 bits
are uncommon, then this technique can be a win,
since only a single test, rather than two, is
necessary to determine if clamping is needed.
On the other hand, if over/underflows are common,
it adds an extra test.
*/
if (val & 0xffffff00) { \
if (val < MLIB_U8_MIN) \
dst = MLIB_U8_MIN; \
else \
dst = MLIB_U8_MAX; \
} else { \
}
if (val >= MLIB_S16_MAX) \
dst = MLIB_S16_MAX; \
else if (val <= MLIB_S16_MIN) \
dst = MLIB_S16_MIN; \
else \
if (val >= MLIB_U16_MAX) \
dst = MLIB_U16_MAX; \
else if (val <= MLIB_U16_MIN) \
dst = MLIB_U16_MIN; \
else \
#endif /* IMG_TYPE == 1 */
#endif /* __sparc */
/***************************************************************/
{
#ifndef __sparc
#endif /* __sparc */
LOAD_KERNEL3();
}
for (c = 0; c < nchannel; c++) {
for (i = 0; i < dx_l; i++) {
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < swid; i++) {
}
for (i = 0; i < dx_r; i++) {
}
for (j = 0; j < hgt; j++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
#ifdef __sparc
#ifdef _NO_LONGLONG
#else /* _NO_LONGLONG */
#endif /* _NO_LONGLONG */
#endif /* __sparc */
#ifndef __sparc
#else /* __sparc */
#ifdef _NO_LONGLONG
#if IMG_TYPE != 1
#else
#endif /* IMG_TYPE != 1 */
#else /* _NO_LONGLONG */
#if IMG_TYPE != 1
#else
#endif /* IMG_TYPE != 1 */
#endif /* _NO_LONGLONG */
#endif /* __sparc */
}
for (; i < wid; i++) {
#ifndef __sparc
#else /* __sparc */
#if IMG_TYPE != 1
#else
#endif /* IMG_TYPE != 1 */
#endif /* __sparc */
}
for (; i < swid; i++) {
}
}
}
#ifdef __sparc
#if IMG_TYPE == 1
{
} else {
}
}
#endif /* IMG_TYPE == 1 */
#endif /* __sparc */
return MLIB_SUCCESS;
}
/***************************************************************/
#ifndef __sparc /* for x86, using integer multiplies is faster */
{
mlib_s32 i, j, c;
#if IMG_TYPE != 1
shift1 = 16;
#else
shift1 = 8;
#endif /* IMG_TYPE != 1 */
/* keep kernel in regs */
delta_chan = 0;
for (c = 0; c < chan1; c++) {
for (j = 0; j < hgt; j++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
}
for (; i < wid; i++) {
}
}
}
return MLIB_SUCCESS;
}
#endif /* __sparc ( for x86, using integer multiplies is faster ) */
/***************************************************************/
{
}
for (c = 0; c < nchannel; c++) {
for (i = 0; i < dx_l; i++) {
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < swid; i++) {
}
for (i = 0; i < dx_r; i++) {
}
for (j = 0; j < hgt; j++) {
/*
* First loop on two first lines of kernel
*/
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
/*
* Second loop on two last lines of kernel
*/
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
/* last pixels */
for (; i < wid; i++) {
}
for (; i < swid; i++) {
}
/* next line */
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
}
for (c = 0; c < nchannel; c++) {
for (i = 0; i < dx_l; i++) {
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < swid; i++) {
}
for (i = 0; i < dx_r; i++) {
}
for (j = 0; j < hgt; j++) {
/*
* First loop
*/
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
/*
* Second loop
*/
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
/*
* 3 loop
*/
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
/* last pixels */
for (; i < wid; i++) {
}
for (; i < swid; i++) {
}
/* next line */
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
#ifndef __sparc /* for x86, using integer multiplies is faster */
{
mlib_s32 i, j, c;
#if IMG_TYPE != 1
shift1 = 16;
#else
shift1 = 8;
#endif /* IMG_TYPE != 1 */
}
else delta_chan1 = 0;
else delta_chan2 = delta_chan1;
else delta_chan3 = delta_chan2;
for (c = 0; c < chan1; c++) {
for (j = 0; j < hgt; j++) {
/*
* First loop
*/
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
}
for (; i < wid; i++) {
}
/*
* Second loop
*/
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
}
for (; i < wid; i++) {
}
/*
* 3 loop
*/
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
}
for (; i < wid; i++) {
}
/* next line */
}
}
return MLIB_SUCCESS;
}
#endif /* __sparc ( for x86, using integer multiplies is faster ) */
/***************************************************************/
#if IMG_TYPE == 1
{
}
for (c = 0; c < nchannel; c++) {
for (i = 0; i < dx_l; i++) {
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < swid; i++) {
}
for (i = 0; i < dx_r; i++) {
}
buff_ind = 0;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (j = 0; j < hgt; j++) {
for (l = 0; l < KSIZE; l++) {
if (l < (KSIZE - 1)) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
}
}
/* last pixels */
for (; i < wid; i++) {
for (l = 0; l < KSIZE; l++) {
}
}
for (; i < swid; i++) {
}
/* next line */
buff_ind++;
}
}
return MLIB_SUCCESS;
}
#endif /* IMG_TYPE == 1 */
/***************************************************************/
const mlib_image *src,
const mlib_d64 *k,
mlib_s32 n,
{
mlib_s32 i, j, c;
}
k_off = 0;
for (c = 0; c < nchannel; c++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (j = 0; j < wid; j++) {
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
}
pk = k;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < hsize; i += 2) {
}
pk += 4;
buff += 4;
}
if (kh == 4) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
if (i < hsize) {
buffd[i] = 0.0;
}
} else if (kh == 3) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
if (i < hsize) {
buffd[i] = 0.0;
}
} else if (kh == 2) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
if (i < hsize) {
buffd[i] = 0.0;
}
} else /* kh == 1 */{
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
if (i < hsize) {
buffd[i] = 0.0;
}
}
/* next line */
}
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
if (scale > 30) {
scale -= 30;
}
mn = m*n;
if (mn > 256) {
if (k == NULL) return MLIB_FAILURE;
}
for (i = 0; i < mn; i++) {
}
}
for (c = 0; c < nchannel; c++) {
for (l = 0; l < n; l++) {
for (i = 0; i < dx_l; i++) {
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < swid; i++) {
}
for (i = 0; i < dx_r; i++) {
}
}
buff_ind = 0;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (j = 0; j < hgt; j++) {
for (l = 0; l < n; l++) {
if (kw == 7) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
}
} else if (kw == 6) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
}
} else if (kw == 5) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
}
} else if (kw == 4) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
}
} else if (kw == 3) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
}
} else /* if (kw == 2) */ {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0.0;
}
}
}
}
}
/* last pixels */
for (; i < wid; i++) {
for (l = 0; l < n; l++) {
}
}
for (; i < swid; i++) {
}
/* next line */
buff_ind++;
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
#ifndef __sparc /* for x86, using integer multiplies is faster */
x >>= shift2; \
CLAMP_STORE(res, x)
{
#if IMG_TYPE != 1
shift1 = 16;
#else
shift1 = 8;
#endif /* IMG_TYPE != 1 */
}
k = mlib_malloc(sizeof(mlib_s32)*(m*n));
if (k == NULL) {
return MLIB_FAILURE;
}
}
for (i = 0; i < m*n; i++) {
}
for (c = 0; c < nchannel; c++) {
for (l = 0; l < n; l++) {
for (i = 0; i < dx_l; i++) {
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (i = 0; i < swid; i++) {
}
for (i = 0; i < dx_r; i++) {
}
}
buff_ind = 0;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (j = 0; j < hgt; j++) {
for (l = 0; l < n; l++) {
if (kw == 7) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0;
buffd[i + 1] = 0;
}
}
} else if (kw == 6) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0;
buffd[i + 1] = 0;
}
}
} else if (kw == 5) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0;
buffd[i + 1] = 0;
}
}
} else if (kw == 4) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0;
buffd[i + 1] = 0;
}
}
} else if (kw == 3) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0;
buffd[i + 1] = 0;
}
}
} else if (kw == 2) {
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0;
buffd[i + 1] = 0;
}
}
} else /* kw == 1 */{
if (l < (n - 1) || off < m) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
} else {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
buffd[i ] = 0;
buffd[i + 1] = 0;
}
}
}
}
}
/* last pixels */
for (; i < wid; i++) {
for (l = 0; l < n; l++) {
}
}
for (; i < swid; i++) {
}
/* next line */
buff_ind++;
}
}
return MLIB_SUCCESS;
}
#endif /* __sparc ( for x86, using integer multiplies is faster ) */
/***************************************************************/