< prev index next >

src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffine_NN.c

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  66  *
  67  */
  68 
  69 #include "mlib_ImageAffine.h"
  70 
  71 /***************************************************************/
  72 #undef  DTYPE
  73 #define DTYPE mlib_u8
  74 
  75 mlib_status mlib_ImageAffine_u8_1ch_nn(mlib_affine_param *param)
  76 {
  77   DECLAREVAR_NN();
  78   DTYPE *dstLineEnd;
  79 
  80   for (j = yStart; j <= yFinish; j++) {
  81     DTYPE pix0;
  82 
  83     CLIP(1);
  84     dstLineEnd = (DTYPE *) dstData + xRight;
  85 
  86 #ifdef __SUNPRO_C
  87 #pragma pipeloop(0)
  88 #endif /* __SUNPRO_C */
  89     for (; dstPixelPtr <= dstLineEnd; dstPixelPtr++) {
  90       ySrc = MLIB_POINTER_SHIFT(Y);
  91       Y += dY;
  92       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc);
  93       xSrc = X >> MLIB_SHIFT;
  94       X += dX;
  95       pix0 = srcPixelPtr[xSrc];
  96       dstPixelPtr[0] = pix0;
  97     }
  98   }
  99 
 100   return MLIB_SUCCESS;
 101 }
 102 
 103 /***************************************************************/
 104 mlib_status mlib_ImageAffine_u8_2ch_nn(mlib_affine_param *param)
 105 {
 106   DECLAREVAR_NN();
 107   DTYPE *dstLineEnd;
 108 
 109   for (j = yStart; j <= yFinish; j++) {
 110     DTYPE pix0, pix1;
 111 
 112     CLIP(2);
 113     dstLineEnd = (DTYPE *) dstData + 2 * xRight;
 114 
 115     ySrc = MLIB_POINTER_SHIFT(Y);
 116     Y += dY;
 117     xSrc = X >> MLIB_SHIFT;
 118     X += dX;
 119     srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
 120     pix0 = srcPixelPtr[0];
 121     pix1 = srcPixelPtr[1];
 122     ySrc = MLIB_POINTER_SHIFT(Y);
 123     Y += dY;
 124     xSrc = X >> MLIB_SHIFT;
 125     X += dX;
 126 #ifdef __SUNPRO_C
 127 #pragma pipeloop(0)
 128 #endif /* __SUNPRO_C */
 129     for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 2) {
 130       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
 131       ySrc = MLIB_POINTER_SHIFT(Y);
 132       Y += dY;
 133       xSrc = X >> MLIB_SHIFT;
 134       X += dX;
 135       dstPixelPtr[0] = pix0;
 136       dstPixelPtr[1] = pix1;
 137       pix0 = srcPixelPtr[0];
 138       pix1 = srcPixelPtr[1];
 139     }
 140 
 141     dstPixelPtr[0] = pix0;
 142     dstPixelPtr[1] = pix1;
 143   }
 144 
 145   return MLIB_SUCCESS;
 146 }
 147 
 148 /***************************************************************/


 152   DTYPE *dstLineEnd;
 153 
 154   for (j = yStart; j <= yFinish; j++) {
 155     DTYPE pix0, pix1, pix2;
 156 
 157     CLIP(3);
 158     dstLineEnd = (DTYPE *) dstData + 3 * xRight;
 159 
 160     ySrc = MLIB_POINTER_SHIFT(Y);
 161     Y += dY;
 162     xSrc = X >> MLIB_SHIFT;
 163     X += dX;
 164     srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
 165     pix0 = srcPixelPtr[0];
 166     pix1 = srcPixelPtr[1];
 167     pix2 = srcPixelPtr[2];
 168     ySrc = MLIB_POINTER_SHIFT(Y);
 169     Y += dY;
 170     xSrc = X >> MLIB_SHIFT;
 171     X += dX;
 172 #ifdef __SUNPRO_C
 173 #pragma pipeloop(0)
 174 #endif /* __SUNPRO_C */
 175     for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
 176       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
 177       ySrc = MLIB_POINTER_SHIFT(Y);
 178       Y += dY;
 179       xSrc = X >> MLIB_SHIFT;
 180       X += dX;
 181       dstPixelPtr[0] = pix0;
 182       dstPixelPtr[1] = pix1;
 183       dstPixelPtr[2] = pix2;
 184       pix0 = srcPixelPtr[0];
 185       pix1 = srcPixelPtr[1];
 186       pix2 = srcPixelPtr[2];
 187     }
 188 
 189     dstPixelPtr[0] = pix0;
 190     dstPixelPtr[1] = pix1;
 191     dstPixelPtr[2] = pix2;
 192   }
 193 
 194   return MLIB_SUCCESS;


 288   DECLAREVAR_NN();
 289   DTYPE *dstLineEnd;
 290 
 291   for (j = yStart; j <= yFinish; j++) {
 292     mlib_s32 pix0, pix1;
 293 
 294     CLIP(2);
 295     dstLineEnd = (DTYPE *) dstData + 2 * xRight;
 296 
 297     ySrc = MLIB_POINTER_SHIFT(Y);
 298     Y += dY;
 299     xSrc = X >> MLIB_SHIFT;
 300     X += dX;
 301     srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
 302     pix0 = srcPixelPtr[0];
 303     pix1 = srcPixelPtr[1];
 304     ySrc = MLIB_POINTER_SHIFT(Y);
 305     Y += dY;
 306     xSrc = X >> MLIB_SHIFT;
 307     X += dX;
 308 #ifdef __SUNPRO_C
 309 #pragma pipeloop(0)
 310 #endif /* __SUNPRO_C */
 311     for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 2) {
 312       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
 313       ySrc = MLIB_POINTER_SHIFT(Y);
 314       Y += dY;
 315       xSrc = X >> MLIB_SHIFT;
 316       X += dX;
 317       dstPixelPtr[0] = pix0;
 318       dstPixelPtr[1] = pix1;
 319       pix0 = srcPixelPtr[0];
 320       pix1 = srcPixelPtr[1];
 321     }
 322 
 323     dstPixelPtr[0] = pix0;
 324     dstPixelPtr[1] = pix1;
 325   }
 326 
 327   return MLIB_SUCCESS;
 328 }
 329 
 330 /***************************************************************/


 334   DTYPE *dstLineEnd;
 335 
 336   for (j = yStart; j <= yFinish; j++) {
 337     mlib_s32 pix0, pix1, pix2;
 338 
 339     CLIP(3);
 340     dstLineEnd = (DTYPE *) dstData + 3 * xRight;
 341 
 342     ySrc = MLIB_POINTER_SHIFT(Y);
 343     Y += dY;
 344     xSrc = X >> MLIB_SHIFT;
 345     X += dX;
 346     srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
 347     pix0 = srcPixelPtr[0];
 348     pix1 = srcPixelPtr[1];
 349     pix2 = srcPixelPtr[2];
 350     ySrc = MLIB_POINTER_SHIFT(Y);
 351     Y += dY;
 352     xSrc = X >> MLIB_SHIFT;
 353     X += dX;
 354 #ifdef __SUNPRO_C
 355 #pragma pipeloop(0)
 356 #endif /* __SUNPRO_C */
 357     for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
 358       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
 359       ySrc = MLIB_POINTER_SHIFT(Y);
 360       Y += dY;
 361       xSrc = X >> MLIB_SHIFT;
 362       X += dX;
 363       dstPixelPtr[0] = pix0;
 364       dstPixelPtr[1] = pix1;
 365       dstPixelPtr[2] = pix2;
 366       pix0 = srcPixelPtr[0];
 367       pix1 = srcPixelPtr[1];
 368       pix2 = srcPixelPtr[2];
 369     }
 370 
 371     dstPixelPtr[0] = pix0;
 372     dstPixelPtr[1] = pix1;
 373     dstPixelPtr[2] = pix2;
 374   }
 375 
 376   return MLIB_SUCCESS;


   1 /*
   2  * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  66  *
  67  */
  68 
  69 #include "mlib_ImageAffine.h"
  70 
  71 /***************************************************************/
  72 #undef  DTYPE
  73 #define DTYPE mlib_u8
  74 
  75 mlib_status mlib_ImageAffine_u8_1ch_nn(mlib_affine_param *param)
  76 {
  77   DECLAREVAR_NN();
  78   DTYPE *dstLineEnd;
  79 
  80   for (j = yStart; j <= yFinish; j++) {
  81     DTYPE pix0;
  82 
  83     CLIP(1);
  84     dstLineEnd = (DTYPE *) dstData + xRight;
  85 



  86     for (; dstPixelPtr <= dstLineEnd; dstPixelPtr++) {
  87       ySrc = MLIB_POINTER_SHIFT(Y);
  88       Y += dY;
  89       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc);
  90       xSrc = X >> MLIB_SHIFT;
  91       X += dX;
  92       pix0 = srcPixelPtr[xSrc];
  93       dstPixelPtr[0] = pix0;
  94     }
  95   }
  96 
  97   return MLIB_SUCCESS;
  98 }
  99 
 100 /***************************************************************/
 101 mlib_status mlib_ImageAffine_u8_2ch_nn(mlib_affine_param *param)
 102 {
 103   DECLAREVAR_NN();
 104   DTYPE *dstLineEnd;
 105 
 106   for (j = yStart; j <= yFinish; j++) {
 107     DTYPE pix0, pix1;
 108 
 109     CLIP(2);
 110     dstLineEnd = (DTYPE *) dstData + 2 * xRight;
 111 
 112     ySrc = MLIB_POINTER_SHIFT(Y);
 113     Y += dY;
 114     xSrc = X >> MLIB_SHIFT;
 115     X += dX;
 116     srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
 117     pix0 = srcPixelPtr[0];
 118     pix1 = srcPixelPtr[1];
 119     ySrc = MLIB_POINTER_SHIFT(Y);
 120     Y += dY;
 121     xSrc = X >> MLIB_SHIFT;
 122     X += dX;



 123     for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 2) {
 124       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
 125       ySrc = MLIB_POINTER_SHIFT(Y);
 126       Y += dY;
 127       xSrc = X >> MLIB_SHIFT;
 128       X += dX;
 129       dstPixelPtr[0] = pix0;
 130       dstPixelPtr[1] = pix1;
 131       pix0 = srcPixelPtr[0];
 132       pix1 = srcPixelPtr[1];
 133     }
 134 
 135     dstPixelPtr[0] = pix0;
 136     dstPixelPtr[1] = pix1;
 137   }
 138 
 139   return MLIB_SUCCESS;
 140 }
 141 
 142 /***************************************************************/


 146   DTYPE *dstLineEnd;
 147 
 148   for (j = yStart; j <= yFinish; j++) {
 149     DTYPE pix0, pix1, pix2;
 150 
 151     CLIP(3);
 152     dstLineEnd = (DTYPE *) dstData + 3 * xRight;
 153 
 154     ySrc = MLIB_POINTER_SHIFT(Y);
 155     Y += dY;
 156     xSrc = X >> MLIB_SHIFT;
 157     X += dX;
 158     srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
 159     pix0 = srcPixelPtr[0];
 160     pix1 = srcPixelPtr[1];
 161     pix2 = srcPixelPtr[2];
 162     ySrc = MLIB_POINTER_SHIFT(Y);
 163     Y += dY;
 164     xSrc = X >> MLIB_SHIFT;
 165     X += dX;



 166     for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
 167       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
 168       ySrc = MLIB_POINTER_SHIFT(Y);
 169       Y += dY;
 170       xSrc = X >> MLIB_SHIFT;
 171       X += dX;
 172       dstPixelPtr[0] = pix0;
 173       dstPixelPtr[1] = pix1;
 174       dstPixelPtr[2] = pix2;
 175       pix0 = srcPixelPtr[0];
 176       pix1 = srcPixelPtr[1];
 177       pix2 = srcPixelPtr[2];
 178     }
 179 
 180     dstPixelPtr[0] = pix0;
 181     dstPixelPtr[1] = pix1;
 182     dstPixelPtr[2] = pix2;
 183   }
 184 
 185   return MLIB_SUCCESS;


 279   DECLAREVAR_NN();
 280   DTYPE *dstLineEnd;
 281 
 282   for (j = yStart; j <= yFinish; j++) {
 283     mlib_s32 pix0, pix1;
 284 
 285     CLIP(2);
 286     dstLineEnd = (DTYPE *) dstData + 2 * xRight;
 287 
 288     ySrc = MLIB_POINTER_SHIFT(Y);
 289     Y += dY;
 290     xSrc = X >> MLIB_SHIFT;
 291     X += dX;
 292     srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
 293     pix0 = srcPixelPtr[0];
 294     pix1 = srcPixelPtr[1];
 295     ySrc = MLIB_POINTER_SHIFT(Y);
 296     Y += dY;
 297     xSrc = X >> MLIB_SHIFT;
 298     X += dX;
 299 


 300     for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 2) {
 301       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 2 * xSrc;
 302       ySrc = MLIB_POINTER_SHIFT(Y);
 303       Y += dY;
 304       xSrc = X >> MLIB_SHIFT;
 305       X += dX;
 306       dstPixelPtr[0] = pix0;
 307       dstPixelPtr[1] = pix1;
 308       pix0 = srcPixelPtr[0];
 309       pix1 = srcPixelPtr[1];
 310     }
 311 
 312     dstPixelPtr[0] = pix0;
 313     dstPixelPtr[1] = pix1;
 314   }
 315 
 316   return MLIB_SUCCESS;
 317 }
 318 
 319 /***************************************************************/


 323   DTYPE *dstLineEnd;
 324 
 325   for (j = yStart; j <= yFinish; j++) {
 326     mlib_s32 pix0, pix1, pix2;
 327 
 328     CLIP(3);
 329     dstLineEnd = (DTYPE *) dstData + 3 * xRight;
 330 
 331     ySrc = MLIB_POINTER_SHIFT(Y);
 332     Y += dY;
 333     xSrc = X >> MLIB_SHIFT;
 334     X += dX;
 335     srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
 336     pix0 = srcPixelPtr[0];
 337     pix1 = srcPixelPtr[1];
 338     pix2 = srcPixelPtr[2];
 339     ySrc = MLIB_POINTER_SHIFT(Y);
 340     Y += dY;
 341     xSrc = X >> MLIB_SHIFT;
 342     X += dX;



 343     for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
 344       srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
 345       ySrc = MLIB_POINTER_SHIFT(Y);
 346       Y += dY;
 347       xSrc = X >> MLIB_SHIFT;
 348       X += dX;
 349       dstPixelPtr[0] = pix0;
 350       dstPixelPtr[1] = pix1;
 351       dstPixelPtr[2] = pix2;
 352       pix0 = srcPixelPtr[0];
 353       pix1 = srcPixelPtr[1];
 354       pix2 = srcPixelPtr[2];
 355     }
 356 
 357     dstPixelPtr[0] = pix0;
 358     dstPixelPtr[1] = pix1;
 359     dstPixelPtr[2] = pix2;
 360   }
 361 
 362   return MLIB_SUCCESS;


< prev index next >