jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c
changeset 38415 acea5f7d354b
parent 25859 3317bb8137f4
equal deleted inserted replaced
38414:3e22d8fd4912 38415:acea5f7d354b
    31  *
    31  *
    32  */
    32  */
    33 
    33 
    34 #include "vis_proto.h"
    34 #include "vis_proto.h"
    35 #include "mlib_image.h"
    35 #include "mlib_image.h"
    36 #include "mlib_ImageColormap.h"
       
    37 #include "mlib_ImageCopy.h"
    36 #include "mlib_ImageCopy.h"
    38 #include "mlib_ImageAffine.h"
    37 #include "mlib_ImageAffine.h"
    39 #include "mlib_v_ImageFilters.h"
    38 #include "mlib_v_ImageFilters.h"
    40 #include "mlib_v_ImageChannelExtract.h"
    39 #include "mlib_v_ImageChannelExtract.h"
    41 
    40 
   714 
   713 
   715   return MLIB_SUCCESS;
   714   return MLIB_SUCCESS;
   716 }
   715 }
   717 
   716 
   718 /***************************************************************/
   717 /***************************************************************/
   719 #define LUT(x)  plut[x]
       
   720 
       
   721 mlib_status FUN_NAME(s16_i)(mlib_affine_param *param,
       
   722                             const void        *colormap)
       
   723 {
       
   724   DECLAREVAR();
       
   725   mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
       
   726   mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
       
   727   mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
       
   728   mlib_s32 max_xsize = param -> max_xsize;
       
   729   mlib_d64 buff[BUF_SIZE], *pbuff = buff;
       
   730 
       
   731   srcYStride /= sizeof(DTYPE);
       
   732 
       
   733   if (max_xsize > BUF_SIZE) {
       
   734     pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
       
   735 
       
   736     if (pbuff == NULL) return MLIB_FAILURE;
       
   737   }
       
   738 
       
   739   dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
       
   740   dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
       
   741   dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
       
   742   dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
       
   743 
       
   744   for (j = yStart; j <= yFinish; j++) {
       
   745     DTYPE *sp;
       
   746 
       
   747     NEW_LINE(1);
       
   748 
       
   749     deltax = DOUBLE_4U16(X, X, X, X);
       
   750     deltay = DOUBLE_4U16(Y, Y, Y, Y);
       
   751 
       
   752 #pragma pipeloop(0)
       
   753     for (i = 0; i < size; i++) {
       
   754       sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
       
   755       s0 = LUT(sp[0]);
       
   756       s1 = LUT(sp[1]);
       
   757       s2 = LUT(sp[srcYStride]);
       
   758       s3 = LUT(sp[srcYStride + 1]);
       
   759 
       
   760       BL_SUM();
       
   761 
       
   762       pbuff[i] = dd;
       
   763       X += dX;
       
   764       Y += dY;
       
   765     }
       
   766 
       
   767     if (nchan == 3) {
       
   768       mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap);
       
   769     } else {
       
   770       mlib_ImageColorTrue2IndexLine_S16_S16_4((void*)pbuff, (void*)dl, size, colormap);
       
   771     }
       
   772   }
       
   773 
       
   774   if (pbuff != buff) {
       
   775     mlib_free(pbuff);
       
   776   }
       
   777 
       
   778   return MLIB_SUCCESS;
       
   779 }
       
   780 
       
   781 /***************************************************************/
       
   782 #undef  DTYPE
       
   783 #define DTYPE mlib_u8
       
   784 
       
   785 mlib_status FUN_NAME(u8_i)(mlib_affine_param *param,
       
   786                            const void        *colormap)
       
   787 {
       
   788   DECLAREVAR();
       
   789   mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
       
   790   mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
       
   791   mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
       
   792   mlib_s32 max_xsize = param -> max_xsize;
       
   793   mlib_d64 buff[BUF_SIZE], *pbuff = buff;
       
   794 
       
   795   if (max_xsize > BUF_SIZE) {
       
   796     pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64));
       
   797 
       
   798     if (pbuff == NULL) return MLIB_FAILURE;
       
   799   }
       
   800 
       
   801   dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */
       
   802   dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */
       
   803   dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF));
       
   804   dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF));
       
   805 
       
   806   for (j = yStart; j <= yFinish; j++) {
       
   807     DTYPE *sp;
       
   808 
       
   809     NEW_LINE(1);
       
   810 
       
   811     deltax = DOUBLE_4U16(X, X, X, X);
       
   812     deltay = DOUBLE_4U16(Y, Y, Y, Y);
       
   813 
       
   814 #pragma pipeloop(0)
       
   815     for (i = 0; i < size; i++) {
       
   816       sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
       
   817       s0 = LUT(sp[0]);
       
   818       s1 = LUT(sp[1]);
       
   819       s2 = LUT(sp[srcYStride]);
       
   820       s3 = LUT(sp[srcYStride + 1]);
       
   821 
       
   822       BL_SUM();
       
   823 
       
   824       pbuff[i] = dd;
       
   825       X += dX;
       
   826       Y += dY;
       
   827     }
       
   828 
       
   829     if (nchan == 3) {
       
   830       mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap);
       
   831     } else {
       
   832       mlib_ImageColorTrue2IndexLine_S16_U8_4((void*)pbuff, (void*)dl, size, colormap);
       
   833     }
       
   834   }
       
   835 
       
   836   if (pbuff != buff) {
       
   837     mlib_free(pbuff);
       
   838   }
       
   839 
       
   840   return MLIB_SUCCESS;
       
   841 }
       
   842 
       
   843 /***************************************************************/