jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageLookUpS32S32Func.c
changeset 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 /*
       
     2  * Copyright 1998-2003 Sun Microsystems, Inc.  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.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 
       
    27 
       
    28 #include "mlib_image.h"
       
    29 #include "mlib_v_ImageLookUpFunc.h"
       
    30 
       
    31 /***************************************************************/
       
    32 #define HALF_U64        (MLIB_U64_CONST(2147483648) * sizeof(table[0][0]))
       
    33 
       
    34 /***************************************************************/
       
    35 void mlib_v_ImageLookUp_S32_S32(const mlib_s32 *src,
       
    36                                 mlib_s32       slb,
       
    37                                 mlib_s32       *dst,
       
    38                                 mlib_s32       dlb,
       
    39                                 mlib_s32       xsize,
       
    40                                 mlib_s32       ysize,
       
    41                                 const mlib_s32 **table,
       
    42                                 mlib_s32       csize)
       
    43 {
       
    44   mlib_s32 i, j, k;
       
    45 
       
    46   dlb >>= 2; slb >>= 2;
       
    47 
       
    48   if (xsize < 2) {
       
    49     for(j = 0; j < ysize; j++, dst += dlb, src += slb){
       
    50       for(k = 0; k < csize; k++) {
       
    51         mlib_s32 *da = dst + k;
       
    52         const mlib_s32 *sa = src + k;
       
    53         const mlib_s32 *tab = (void *)&(((mlib_u8 **)table)[k][HALF_U64]);
       
    54 
       
    55         for(i = 0; i < xsize; i++, da += csize, sa += csize)
       
    56         *da=tab[*sa];
       
    57       }
       
    58     }
       
    59 
       
    60   } else {
       
    61     for(j = 0; j < ysize; j++, dst += dlb, src += slb) {
       
    62 #pragma pipeloop(0)
       
    63       for(k = 0; k < csize; k++) {
       
    64         mlib_s32 *da = dst + k;
       
    65         const mlib_s32 *sa = src + k;
       
    66         const mlib_s32 *tab = (void *)&(((mlib_u8 **)table)[k][HALF_U64]);
       
    67         mlib_s32 s0, t0, s1, t1;
       
    68 
       
    69         s0 = sa[0];
       
    70         s1 = sa[csize];
       
    71         sa += 2*csize;
       
    72 
       
    73         for(i = 0; i < xsize - 3; i+=2, da += 2*csize, sa += 2*csize) {
       
    74           t0 = tab[s0];
       
    75           t1 = tab[s1];
       
    76           s0 = sa[0];
       
    77           s1 = sa[csize];
       
    78           da[0] = t0;
       
    79           da[csize] = t1;
       
    80         }
       
    81 
       
    82         t0 = tab[s0];
       
    83         t1 = tab[s1];
       
    84         da[0] = t0;
       
    85         da[csize] = t1;
       
    86 
       
    87         if (xsize & 1) da[2*csize] = tab[sa[0]];
       
    88       }
       
    89     }
       
    90   }
       
    91 }
       
    92 
       
    93 /***************************************************************/