< prev index next >

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

Print this page




 165 #define PREPAREVARS(type)                                        \
 166   type *psrc = (type *) mlib_ImageGetData(src);                  \
 167   type *pdst = (type *) mlib_ImageGetData(dst);                  \
 168   mlib_s32 src_height = mlib_ImageGetHeight(src);                \
 169   mlib_s32 src_width  = mlib_ImageGetWidth(src);                 \
 170   mlib_s32 src_stride = mlib_ImageGetStride(src) / sizeof(type); \
 171   mlib_s32 dst_stride = mlib_ImageGetStride(dst) / sizeof(type); \
 172   mlib_s32 chan = mlib_ImageGetChannels(dst);                    \
 173   mlib_s32 i, j;                                                 \
 174                                                                  \
 175   src_width *= chan;                                             \
 176   if (src_width == src_stride && src_width == dst_stride) {      \
 177     src_width *= src_height;                                     \
 178     src_height = 1;                                              \
 179   }
 180 
 181 /***************************************************************/
 182 #define STRIP(pd, ps, w, h, data_type) {                        \
 183   data_type s0, s1;                                             \
 184   for ( i = 0; i < h; i++ ) {                                   \
 185     if (j = w & 1)                                              \
 186       pd[i * dst_stride] = ps[i * src_stride];                  \
 187     for (; j < w; j += 2) {                                     \
 188       s0 = ps[i * src_stride + j];                              \
 189       s1 = ps[i * src_stride + j + 1];                          \
 190       pd[i * dst_stride + j]   = s0;                            \
 191       pd[i * dst_stride + j + 1] = s1;                          \
 192     }                                                           \
 193   }                                                             \
 194 }
 195 
 196 /***************************************************************/
 197 /*
 198  * Both bit offsets of source and distination are the same
 199  */
 200 
 201 void mlib_ImageCopy_bit_al(const mlib_u8 *sa,
 202                            mlib_u8       *da,
 203                            mlib_s32      size,
 204                            mlib_s32      offset)
 205 {


 529 
 530     for (; j < src_width; j++)
 531       pdst_row[j] = psrc_row[j];
 532   }
 533 }
 534 
 535 /***************************************************************/
 536 void mlib_c_ImageCopy_s32(const mlib_image       *src,
 537                           mlib_image *dst)
 538 {
 539   PREPAREVARS(mlib_u32);
 540   if (src_width < 4) {
 541     STRIP(pdst, psrc, src_width, src_height, mlib_u32);
 542     return;
 543   }
 544 
 545   for (i = 0; i < src_height; i++) {
 546     mlib_u32 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
 547 
 548     if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
 549       if (j = ((mlib_s32) ((mlib_addr) psrc_row & 4) >> 2)) {
 550         pdst_row[0] = psrc_row[0];
 551       }
 552 
 553 #ifdef __SUNPRO_C
 554 #pragma pipeloop(0)
 555 #endif /* __SUNPRO_C */
 556       for (; j <= (src_width - 2); j += 2) {
 557         TYPE_64BIT dsrc0 = *((TYPE_64BIT *) (psrc_row + j));
 558 
 559         *((TYPE_64BIT *) (pdst_row + j)) = dsrc0;
 560       }
 561     }
 562     else {
 563 
 564 #ifdef _NO_LONGLONG
 565 
 566 #ifdef __SUNPRO_C
 567 #pragma pipeloop(0)
 568 #endif /* __SUNPRO_C */
 569       for (j = 0; j <= (src_width - 1); j++) {
 570         *((mlib_s32 *) (pdst_row + j)) = *((mlib_s32 *) (psrc_row + j));
 571       }
 572 
 573 #else
 574 
 575       {
 576         mlib_u64 *ps, src0, src1;
 577 
 578         if (j = ((mlib_s32) ((mlib_addr) pdst_row & 4) >> 2))
 579           pdst_row[0] = psrc_row[0];
 580         ps = (mlib_u64 *) (psrc_row + j - 1);
 581         src1 = ps[0];
 582 #ifdef __SUNPRO_C
 583 #pragma pipeloop(0)
 584 #endif /* __SUNPRO_C */
 585         for (; j <= (src_width - 2); j += 2) {
 586           src0 = src1;
 587           src1 = ps[1];
 588 #ifdef _LITTLE_ENDIAN
 589           *((mlib_s64 *) (pdst_row + j)) = (src0 >> 32) | (src1 << 32);
 590 #else
 591           *((mlib_s64 *) (pdst_row + j)) = (src0 << 32) | (src1 >> 32);
 592 #endif /* _LITTLE_ENDIAN */
 593           ps++;
 594         }
 595       }
 596 #endif /* _NO_LONGLONG */
 597     }
 598 




 165 #define PREPAREVARS(type)                                        \
 166   type *psrc = (type *) mlib_ImageGetData(src);                  \
 167   type *pdst = (type *) mlib_ImageGetData(dst);                  \
 168   mlib_s32 src_height = mlib_ImageGetHeight(src);                \
 169   mlib_s32 src_width  = mlib_ImageGetWidth(src);                 \
 170   mlib_s32 src_stride = mlib_ImageGetStride(src) / sizeof(type); \
 171   mlib_s32 dst_stride = mlib_ImageGetStride(dst) / sizeof(type); \
 172   mlib_s32 chan = mlib_ImageGetChannels(dst);                    \
 173   mlib_s32 i, j;                                                 \
 174                                                                  \
 175   src_width *= chan;                                             \
 176   if (src_width == src_stride && src_width == dst_stride) {      \
 177     src_width *= src_height;                                     \
 178     src_height = 1;                                              \
 179   }
 180 
 181 /***************************************************************/
 182 #define STRIP(pd, ps, w, h, data_type) {                        \
 183   data_type s0, s1;                                             \
 184   for ( i = 0; i < h; i++ ) {                                   \
 185     if ((j = (w & 1)))                                              \
 186       pd[i * dst_stride] = ps[i * src_stride];                  \
 187     for (; j < w; j += 2) {                                     \
 188       s0 = ps[i * src_stride + j];                              \
 189       s1 = ps[i * src_stride + j + 1];                          \
 190       pd[i * dst_stride + j]   = s0;                            \
 191       pd[i * dst_stride + j + 1] = s1;                          \
 192     }                                                           \
 193   }                                                             \
 194 }
 195 
 196 /***************************************************************/
 197 /*
 198  * Both bit offsets of source and distination are the same
 199  */
 200 
 201 void mlib_ImageCopy_bit_al(const mlib_u8 *sa,
 202                            mlib_u8       *da,
 203                            mlib_s32      size,
 204                            mlib_s32      offset)
 205 {


 529 
 530     for (; j < src_width; j++)
 531       pdst_row[j] = psrc_row[j];
 532   }
 533 }
 534 
 535 /***************************************************************/
 536 void mlib_c_ImageCopy_s32(const mlib_image       *src,
 537                           mlib_image *dst)
 538 {
 539   PREPAREVARS(mlib_u32);
 540   if (src_width < 4) {
 541     STRIP(pdst, psrc, src_width, src_height, mlib_u32);
 542     return;
 543   }
 544 
 545   for (i = 0; i < src_height; i++) {
 546     mlib_u32 *psrc_row = psrc + i * src_stride, *pdst_row = pdst + i * dst_stride;
 547 
 548     if (!(((mlib_addr) psrc_row ^ (mlib_addr) pdst_row) & 7)) {
 549       if ((j = ((mlib_s32) ((mlib_addr) psrc_row & 4) >> 2))) {
 550         pdst_row[0] = psrc_row[0];
 551       }
 552 
 553 #ifdef __SUNPRO_C
 554 #pragma pipeloop(0)
 555 #endif /* __SUNPRO_C */
 556       for (; j <= (src_width - 2); j += 2) {
 557         TYPE_64BIT dsrc0 = *((TYPE_64BIT *) (psrc_row + j));
 558 
 559         *((TYPE_64BIT *) (pdst_row + j)) = dsrc0;
 560       }
 561     }
 562     else {
 563 
 564 #ifdef _NO_LONGLONG
 565 
 566 #ifdef __SUNPRO_C
 567 #pragma pipeloop(0)
 568 #endif /* __SUNPRO_C */
 569       for (j = 0; j <= (src_width - 1); j++) {
 570         *((mlib_s32 *) (pdst_row + j)) = *((mlib_s32 *) (psrc_row + j));
 571       }
 572 
 573 #else
 574 
 575       {
 576         mlib_u64 *ps, src0, src1;
 577 
 578         if ((j = ((mlib_s32) ((mlib_addr) pdst_row & 4) >> 2)))
 579           pdst_row[0] = psrc_row[0];
 580         ps = (mlib_u64 *) (psrc_row + j - 1);
 581         src1 = ps[0];
 582 #ifdef __SUNPRO_C
 583 #pragma pipeloop(0)
 584 #endif /* __SUNPRO_C */
 585         for (; j <= (src_width - 2); j += 2) {
 586           src0 = src1;
 587           src1 = ps[1];
 588 #ifdef _LITTLE_ENDIAN
 589           *((mlib_s64 *) (pdst_row + j)) = (src0 >> 32) | (src1 << 32);
 590 #else
 591           *((mlib_s64 *) (pdst_row + j)) = (src0 << 32) | (src1 >> 32);
 592 #endif /* _LITTLE_ENDIAN */
 593           ps++;
 594         }
 595       }
 596 #endif /* _NO_LONGLONG */
 597     }
 598 


< prev index next >