/*
* 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
* Image affine transformation with Bicubic filtering
* SYNOPSIS
* mlib_status mlib_ImageAffine_[u8|s16|u16]_?ch_bc(mlib_s32 *leftEdges,
* mlib_s32 *rightEdges,
* mlib_s32 *xStarts,
* mlib_s32 *yStarts,
* mlib_s32 *sides,
* mlib_u8 *dstData,
* mlib_u8 **lineAddr,
* mlib_s32 dstYStride,
* mlib_s32 is_affine,
* mlib_s32 srcYStride,
* mlib_filter filter)
*
*
* ARGUMENTS
* leftEdges array[dstHeight] of xLeft coordinates
* RightEdges array[dstHeight] of xRight coordinates
* xStarts array[dstHeight] of xStart * 65536 coordinates
* yStarts array[dstHeight] of yStart * 65536 coordinates
* sides output array[4]. sides[0] is yStart, sides[1] is yFinish,
* sides[2] is dx * 65536, sides[3] is dy * 65536
* dstData pointer to the first pixel on (yStart - 1) line
* lineAddr array[srcHeight] of pointers to the first pixel on
* the corresponding lines
* dstYStride stride of destination image
* is_affine indicator (Affine - GridWarp)
* srcYStride stride of source image
* filter type of resampling filter
*
* DESCRIPTION
* The functions step along the lines from xLeft to xRight and apply
* the bicubic filtering.
*
*/
#include "mlib_ImageAffine.h"
/***************************************************************/
#ifdef __sparc /* for SPARC, using floating-point multiplies is faster */
#ifdef MLIB_USE_FTOI_CLAMPING
#else
if (val0 >= MLIB_S32_MAX) \
DST = MLIB_U8_MAX; \
else if (val0 <= MLIB_S32_MIN) \
DST = MLIB_U8_MIN; \
else \
#endif /* MLIB_USE_FTOI_CLAMPING */
/***************************************************************/
{
if (filter == MLIB_BICUBIC) {
}
else {
}
CLIP(1);
s0 = srcPixelPtr[0];
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
X += dX;
Y += dY;
s0 = srcPixelPtr[0];
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
if (filter == MLIB_BICUBIC) {
}
else {
}
CLIP(2);
for (k = 0; k < 2; k++) {
s0 = srcPixelPtr[0];
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
s0 = srcPixelPtr[0];
}
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
if (filter == MLIB_BICUBIC) {
}
else {
}
CLIP(3);
for (k = 0; k < 3; k++) {
s0 = srcPixelPtr[0];
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
s0 = srcPixelPtr[0];
}
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
if (filter == MLIB_BICUBIC) {
}
else {
}
CLIP(4);
for (k = 0; k < 4; k++) {
s0 = srcPixelPtr[0];
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
s0 = srcPixelPtr[0];
}
}
}
return MLIB_SUCCESS;
}
#else /* for x86, using integer multiplies is faster */
/***************************************************************/
/* 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 (val0 & 0xffffff00) { \
if (val0 < MLIB_U8_MIN) \
DST = MLIB_U8_MIN; \
else \
DST = MLIB_U8_MAX; \
} else { \
}
/***************************************************************/
{
if (filter == MLIB_BICUBIC) {
}
else {
}
CLIP(1);
s0 = srcPixelPtr[0];
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
X += dX;
Y += dY;
s0 = srcPixelPtr[0];
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
if (filter == MLIB_BICUBIC) {
}
else {
}
CLIP(2);
for (k = 0; k < 2; k++) {
s0 = srcPixelPtr[0];
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
s0 = srcPixelPtr[0];
}
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
if (filter == MLIB_BICUBIC) {
}
else {
}
CLIP(3);
for (k = 0; k < 3; k++) {
s0 = srcPixelPtr[0];
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
s0 = srcPixelPtr[0];
}
}
}
return MLIB_SUCCESS;
}
/***************************************************************/
{
if (filter == MLIB_BICUBIC) {
}
else {
}
CLIP(4);
for (k = 0; k < 4; k++) {
s0 = srcPixelPtr[0];
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
s0 = srcPixelPtr[0];
}
}
}
return MLIB_SUCCESS;
}
#endif /* __sparc ( for SPARC, using floating-point multiplies is faster ) */
/***************************************************************/