1/* 2 * Copyright (c) 1998, 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 23 * 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/***************************************************************/ 35void 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/***************************************************************/ 94