< prev index next >

src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c

Print this page
rev 14292 : remove Index


  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
  23  * questions.
  24  */
  25 
  26 
  27 
  28 /*
  29  *      The functions step along the lines from xLeft to xRight and apply
  30  *      the bilinear filtering.
  31  *
  32  */
  33 
  34 #include "vis_proto.h"
  35 #include "mlib_image.h"
  36 #include "mlib_ImageColormap.h"
  37 #include "mlib_ImageCopy.h"
  38 #include "mlib_ImageAffine.h"
  39 #include "mlib_v_ImageFilters.h"
  40 #include "mlib_v_ImageChannelExtract.h"
  41 
  42 /***************************************************************/
  43 /*#define MLIB_VIS2*/
  44 
  45 /***************************************************************/
  46 #define DTYPE mlib_u8
  47 
  48 #define FUN_NAME(CHAN) mlib_ImageAffine_u8_##CHAN##_bl
  49 
  50 /***************************************************************/
  51 static mlib_status FUN_NAME(2ch_na)(mlib_affine_param *param);
  52 static mlib_status FUN_NAME(4ch_na)(mlib_affine_param *param);
  53 
  54 /***************************************************************/
  55 #ifdef MLIB_VIS2
  56 #define MLIB_WRITE_BMASK(bmask) vis_write_bmask(bmask, 0)


 700       vis_alignaddr(sp, srcYStride);
 701       sp1 = AL_ADDR(sp, srcYStride);
 702       s1 = vis_faligndata(sp1[0], sp1[1]);
 703 
 704       PROCESS_4CH(vis_read_hi(s0), vis_read_lo(s0), vis_read_hi(s1), vis_read_lo(s1));
 705 
 706       pbuff[i] = vis_fpack16(dd);
 707       X += dX;
 708       Y += dY;
 709     }
 710 
 711     mlib_ImageCopy_na((mlib_u8*)pbuff, dl, 4*size);
 712   }
 713 
 714   if (pbuff != buff) {
 715     mlib_free(pbuff);
 716   }
 717 
 718   return MLIB_SUCCESS;
 719 }
 720 
 721 /***************************************************************/
 722 #define LUT(x)  plut[x]
 723 
 724 mlib_status FUN_NAME(u8_i)(mlib_affine_param *param,
 725                            const void        *colormap)
 726 {
 727   DECLAREVAR();
 728   mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
 729   mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
 730   mlib_f32 *plut = (mlib_f32*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
 731   mlib_s32 max_xsize = param -> max_xsize;
 732   mlib_f32 buff[BUF_SIZE], *pbuff = buff;
 733 
 734   if (max_xsize > BUF_SIZE) {
 735     pbuff = mlib_malloc(max_xsize*sizeof(mlib_f32));
 736 
 737     if (pbuff == NULL) return MLIB_FAILURE;
 738   }
 739 
 740   vis_write_gsr(3 << 3);
 741 
 742   for (j = yStart; j <= yFinish; j++) {
 743     mlib_f32 s0, s1, s2, s3;
 744     DTYPE    *sp;
 745 
 746     NEW_LINE(1);
 747 
 748 #pragma pipeloop(0)
 749     for (i = 0; i < size; i++) {
 750       GET_FILTER_XY();
 751 
 752       sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
 753       s0 = LUT(sp[0]);
 754       s1 = LUT(sp[1]);
 755       s2 = LUT(sp[srcYStride]);
 756       s3 = LUT(sp[srcYStride + 1]);
 757 
 758       PROCESS_4CH(s0, s1, s2, s3);
 759 
 760       pbuff[i] = vis_fpack16(dd);
 761       X += dX;
 762       Y += dY;
 763     }
 764 
 765     if (nchan == 3) {
 766       mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap);
 767     } else {
 768       mlib_ImageColorTrue2IndexLine_U8_U8_4((void*)pbuff, (void*)dl, size, colormap);
 769     }
 770   }
 771 
 772   if (pbuff != buff) {
 773     mlib_free(pbuff);
 774   }
 775 
 776   return MLIB_SUCCESS;
 777 }
 778 
 779 /***************************************************************/
 780 #undef  DTYPE
 781 #define DTYPE mlib_s16
 782 
 783 mlib_status FUN_NAME(s16_i)(mlib_affine_param *param,
 784                             const void        *colormap)
 785 {
 786   DECLAREVAR();
 787   mlib_s32 nchan   = mlib_ImageGetLutChannels(colormap);
 788   mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap);
 789   mlib_f32 *plut = (mlib_f32*)mlib_ImageGetLutNormalTable(colormap) - lut_off;
 790   mlib_s32 max_xsize = param -> max_xsize;
 791   mlib_f32 buff[BUF_SIZE], *pbuff = buff;
 792 
 793   srcYStride /= sizeof(DTYPE);
 794 
 795   if (max_xsize > BUF_SIZE) {
 796     pbuff = mlib_malloc(max_xsize*sizeof(mlib_f32));
 797 
 798     if (pbuff == NULL) return MLIB_FAILURE;
 799   }
 800 
 801   vis_write_gsr(3 << 3);
 802 
 803   for (j = yStart; j <= yFinish; j++) {
 804     mlib_f32 s0, s1, s2, s3;
 805     DTYPE    *sp;
 806 
 807     NEW_LINE(1);
 808 
 809 #pragma pipeloop(0)
 810     for (i = 0; i < size; i++) {
 811       GET_FILTER_XY();
 812 
 813       sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT);
 814       s0 = LUT(sp[0]);
 815       s1 = LUT(sp[1]);
 816       s2 = LUT(sp[srcYStride]);
 817       s3 = LUT(sp[srcYStride + 1]);
 818 
 819       PROCESS_4CH(s0, s1, s2, s3);
 820 
 821       pbuff[i] = vis_fpack16(dd);
 822       X += dX;
 823       Y += dY;
 824     }
 825 
 826     if (nchan == 3) {
 827       mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap);
 828     } else {
 829       mlib_ImageColorTrue2IndexLine_U8_S16_4((void*)pbuff, (void*)dl, size, colormap);
 830     }
 831   }
 832 
 833   if (pbuff != buff) {
 834     mlib_free(pbuff);
 835   }
 836 
 837   return MLIB_SUCCESS;
 838 }
 839 
 840 /***************************************************************/
 841 const type_affine_i_fun mlib_AffineFunArr_bl_i[] = {
 842   mlib_ImageAffine_u8_u8_i_bl,
 843   mlib_ImageAffine_u8_u8_i_bl,
 844   mlib_ImageAffine_u8_s16_i_bl,
 845   mlib_ImageAffine_u8_s16_i_bl,
 846   mlib_ImageAffine_s16_u8_i_bl,
 847   mlib_ImageAffine_s16_u8_i_bl,
 848   mlib_ImageAffine_s16_s16_i_bl,
 849   mlib_ImageAffine_s16_s16_i_bl
 850 };
 851 
 852 /***************************************************************/


  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
  23  * questions.
  24  */
  25 
  26 
  27 
  28 /*
  29  *      The functions step along the lines from xLeft to xRight and apply
  30  *      the bilinear filtering.
  31  *
  32  */
  33 
  34 #include "vis_proto.h"
  35 #include "mlib_image.h"

  36 #include "mlib_ImageCopy.h"
  37 #include "mlib_ImageAffine.h"
  38 #include "mlib_v_ImageFilters.h"
  39 #include "mlib_v_ImageChannelExtract.h"
  40 
  41 /***************************************************************/
  42 /*#define MLIB_VIS2*/
  43 
  44 /***************************************************************/
  45 #define DTYPE mlib_u8
  46 
  47 #define FUN_NAME(CHAN) mlib_ImageAffine_u8_##CHAN##_bl
  48 
  49 /***************************************************************/
  50 static mlib_status FUN_NAME(2ch_na)(mlib_affine_param *param);
  51 static mlib_status FUN_NAME(4ch_na)(mlib_affine_param *param);
  52 
  53 /***************************************************************/
  54 #ifdef MLIB_VIS2
  55 #define MLIB_WRITE_BMASK(bmask) vis_write_bmask(bmask, 0)


 699       vis_alignaddr(sp, srcYStride);
 700       sp1 = AL_ADDR(sp, srcYStride);
 701       s1 = vis_faligndata(sp1[0], sp1[1]);
 702 
 703       PROCESS_4CH(vis_read_hi(s0), vis_read_lo(s0), vis_read_hi(s1), vis_read_lo(s1));
 704 
 705       pbuff[i] = vis_fpack16(dd);
 706       X += dX;
 707       Y += dY;
 708     }
 709 
 710     mlib_ImageCopy_na((mlib_u8*)pbuff, dl, 4*size);
 711   }
 712 
 713   if (pbuff != buff) {
 714     mlib_free(pbuff);
 715   }
 716 
 717   return MLIB_SUCCESS;
 718 }



































































































































 719 
 720 /***************************************************************/
< prev index next >