PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/java-1.7.0-openjdk/openjdk/jdk/src/solaris/native/sun/awt/medialib/mlib_v_ImageLookUpS16S32Func.c

#
C | 388 lines | 292 code | 60 blank | 36 comment | 26 complexity | f65f39108efe779721de1b653d6398f3 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause-No-Nuclear-License-2014, LGPL-3.0, LGPL-2.0
  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. #include "vis_proto.h"
  26. #include "mlib_image.h"
  27. #include "mlib_v_ImageLookUpFunc.h"
  28. /***************************************************************/
  29. static void mlib_v_ImageLookUp_S16_S32_124_D1(const mlib_s16 *src,
  30. mlib_f32 *dst,
  31. mlib_s32 xsize,
  32. const mlib_f32 *table0,
  33. const mlib_f32 *table1,
  34. const mlib_f32 *table2,
  35. const mlib_f32 *table3);
  36. static void mlib_v_ImageLookUp_S16_S32_3_D1(const mlib_s16 *src,
  37. mlib_f32 *dst,
  38. mlib_s32 xsize,
  39. const mlib_f32 *table0,
  40. const mlib_f32 *table1,
  41. const mlib_f32 *table2);
  42. /***************************************************************/
  43. void mlib_v_ImageLookUp_S16_S32_124_D1(const mlib_s16 *src,
  44. mlib_f32 *dst,
  45. mlib_s32 xsize,
  46. const mlib_f32 *table0,
  47. const mlib_f32 *table1,
  48. const mlib_f32 *table2,
  49. const mlib_f32 *table3)
  50. {
  51. mlib_s32 *sa; /* aligned pointer to source data */
  52. mlib_s16 *sp; /* pointer to source data */
  53. mlib_s32 s0, s1; /* source data */
  54. mlib_f32 *dp; /* aligned pointer to destination */
  55. mlib_f32 acc0, acc1; /* destination data */
  56. mlib_f32 acc2, acc3; /* destination data */
  57. mlib_s32 i; /* loop variable */
  58. mlib_s32 s00, s01, s02, s03;
  59. sa = (mlib_s32*)src;
  60. dp = dst;
  61. i = 0;
  62. if (xsize >= 4) {
  63. s0 = *sa++;
  64. s1 = *sa++;
  65. s00 = (s0 >> 14) & (~3);
  66. s01 = ((s0 << 16) >> 14);
  67. #pragma pipeloop(0)
  68. for(i = 0; i <= xsize - 8; i+=4, dp += 4) {
  69. s02 = (s1 >> 14) & (~3);
  70. s03 = ((s1 << 16) >> 14);
  71. acc0 = *(mlib_f32*)((mlib_u8*)table0 + s00);
  72. acc1 = *(mlib_f32*)((mlib_u8*)table1 + s01);
  73. acc2 = *(mlib_f32*)((mlib_u8*)table2 + s02);
  74. acc3 = *(mlib_f32*)((mlib_u8*)table3 + s03);
  75. s0 = *sa++;
  76. s1 = *sa++;
  77. s00 = (s0 >> 14) & (~3);
  78. s01 = ((s0 << 16) >> 14);
  79. dp[0] = acc0;
  80. dp[1] = acc1;
  81. dp[2] = acc2;
  82. dp[3] = acc3;
  83. }
  84. s02 = (s1 >> 14) & (~3);
  85. s03 = ((s1 << 16) >> 14);
  86. acc0 = *(mlib_f32*)((mlib_u8*)table0 + s00);
  87. acc1 = *(mlib_f32*)((mlib_u8*)table1 + s01);
  88. acc2 = *(mlib_f32*)((mlib_u8*)table2 + s02);
  89. acc3 = *(mlib_f32*)((mlib_u8*)table3 + s03);
  90. dp[0] = acc0;
  91. dp[1] = acc1;
  92. dp[2] = acc2;
  93. dp[3] = acc3;
  94. dp += 4;
  95. i += 4;
  96. }
  97. sp = (mlib_s16*)sa;
  98. if ( i < xsize ) {
  99. *dp++ = table0[sp[0]];
  100. i++; sp++;
  101. }
  102. if ( i < xsize ) {
  103. *dp++ = table1[sp[0]];
  104. i++; sp++;
  105. }
  106. if ( i < xsize ) {
  107. *dp++ = table2[sp[0]];
  108. }
  109. }
  110. /***************************************************************/
  111. void mlib_v_ImageLookUp_S16_S32_1(const mlib_s16 *src,
  112. mlib_s32 slb,
  113. mlib_s32 *dst,
  114. mlib_s32 dlb,
  115. mlib_s32 xsize,
  116. mlib_s32 ysize,
  117. const mlib_s32 **table)
  118. {
  119. mlib_s16 *sl;
  120. mlib_s32 *dl;
  121. mlib_f32 *tab = (mlib_f32*)(&table[0][32768]);
  122. mlib_s32 j;
  123. sl = (void *)src;
  124. dl = dst;
  125. /* row loop */
  126. for (j = 0; j < ysize; j ++) {
  127. mlib_s16 *sp = sl;
  128. mlib_f32 *dp = (mlib_f32*)dl;
  129. mlib_s32 off, size = xsize;
  130. off = (mlib_s32)(((4 - ((mlib_addr)sp & 3)) & 3) >> 1);
  131. off = (off < size) ? off : size;
  132. if (off == 1) {
  133. *dp++ = tab[(*sp++)];
  134. size--;
  135. }
  136. if (size > 0) {
  137. mlib_v_ImageLookUp_S16_S32_124_D1(sp, dp, size, tab, tab, tab, tab);
  138. }
  139. sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
  140. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  141. }
  142. }
  143. /***************************************************************/
  144. void mlib_v_ImageLookUp_S16_S32_2(const mlib_s16 *src,
  145. mlib_s32 slb,
  146. mlib_s32 *dst,
  147. mlib_s32 dlb,
  148. mlib_s32 xsize,
  149. mlib_s32 ysize,
  150. const mlib_s32 **table)
  151. {
  152. mlib_s16 *sl;
  153. mlib_s32 *dl;
  154. mlib_f32 *tab;
  155. mlib_s32 j;
  156. sl = (void *)src;
  157. dl = dst;
  158. /* row loop */
  159. for (j = 0; j < ysize; j ++) {
  160. mlib_s16 *sp = sl;
  161. mlib_f32 *dp = (mlib_f32*)dl;
  162. mlib_s32 off, size = xsize * 2;
  163. mlib_f32 *tab0 = (mlib_f32*)(&table[0][32768]);
  164. mlib_f32 *tab1 = (mlib_f32*)(&table[1][32768]);
  165. off = (mlib_s32)(((4 - ((mlib_addr)sp & 3)) & 3) >> 1);
  166. off = (off < size) ? off : size;
  167. if ((off & 1) != 0) {
  168. *dp++ = tab0[(*sp++)];
  169. size--;
  170. tab = tab0; tab0 = tab1; tab1 = tab;
  171. }
  172. if (size > 0) {
  173. mlib_v_ImageLookUp_S16_S32_124_D1(sp, dp, size, tab0, tab1, tab0, tab1);
  174. }
  175. sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
  176. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  177. }
  178. }
  179. /***************************************************************/
  180. void mlib_v_ImageLookUp_S16_S32_4(const mlib_s16 *src,
  181. mlib_s32 slb,
  182. mlib_s32 *dst,
  183. mlib_s32 dlb,
  184. mlib_s32 xsize,
  185. mlib_s32 ysize,
  186. const mlib_s32 **table)
  187. {
  188. mlib_s16 *sl;
  189. mlib_s32 *dl;
  190. mlib_f32 *tab;
  191. mlib_s32 j;
  192. sl = (void *)src;
  193. dl = dst;
  194. /* row loop */
  195. for (j = 0; j < ysize; j ++) {
  196. mlib_s16 *sp = sl;
  197. mlib_f32 *dp = (mlib_f32*)dl;
  198. mlib_f32 *tab0 = (mlib_f32*)(&table[0][32768]);
  199. mlib_f32 *tab1 = (mlib_f32*)(&table[1][32768]);
  200. mlib_f32 *tab2 = (mlib_f32*)(&table[2][32768]);
  201. mlib_f32 *tab3 = (mlib_f32*)(&table[3][32768]);
  202. mlib_s32 off, size = xsize * 4;
  203. off = (mlib_s32)(((4 - ((mlib_addr)sp & 3)) & 3) >> 1);
  204. off = (off < size) ? off : size;
  205. if (off == 1) {
  206. *dp++ = tab0[(*sp++)];
  207. tab = tab0; tab0 = tab1;
  208. tab1 = tab2; tab2 = tab3; tab3 = tab;
  209. size--;
  210. }
  211. if (size > 0) {
  212. mlib_v_ImageLookUp_S16_S32_124_D1(sp, dp, size, tab0, tab1, tab2, tab3);
  213. }
  214. sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
  215. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  216. }
  217. }
  218. /***************************************************************/
  219. void mlib_v_ImageLookUp_S16_S32_3_D1(const mlib_s16 *src,
  220. mlib_f32 *dst,
  221. mlib_s32 xsize,
  222. const mlib_f32 *table0,
  223. const mlib_f32 *table1,
  224. const mlib_f32 *table2)
  225. {
  226. mlib_s32 *sa; /* aligned pointer to source data */
  227. mlib_s16 *sp; /* pointer to source data */
  228. mlib_s32 s0, s1; /* source data */
  229. mlib_f32 *dp; /* aligned pointer to destination */
  230. mlib_f32 acc0, acc1; /* destination data */
  231. mlib_f32 acc2, acc3; /* destination data */
  232. mlib_s32 i; /* loop variable */
  233. const mlib_f32 *table;
  234. mlib_s32 s00, s01, s02, s03;
  235. sa = (mlib_s32*)src;
  236. dp = dst;
  237. i = 0;
  238. if (xsize >= 4) {
  239. s0 = *sa++;
  240. s1 = *sa++;
  241. s00 = (s0 >> 14) & (~3);
  242. s01 = ((s0 << 16) >> 14);
  243. #pragma pipeloop(0)
  244. for(i = 0; i <= xsize - 8; i+=4, dp += 4) {
  245. s02 = (s1 >> 14) & (~3);
  246. s03 = ((s1 << 16) >> 14);
  247. acc0 = *(mlib_f32*)((mlib_u8*)table0 + s00);
  248. acc1 = *(mlib_f32*)((mlib_u8*)table1 + s01);
  249. acc2 = *(mlib_f32*)((mlib_u8*)table2 + s02);
  250. acc3 = *(mlib_f32*)((mlib_u8*)table0 + s03);
  251. s0 = *sa++;
  252. s1 = *sa++;
  253. s00 = (s0 >> 14) & (~3);
  254. s01 = ((s0 << 16) >> 14);
  255. table = table0; table0 = table1;
  256. table1 = table2; table2 = table;
  257. dp[0] = acc0;
  258. dp[1] = acc1;
  259. dp[2] = acc2;
  260. dp[3] = acc3;
  261. }
  262. s02 = (s1 >> 14) & (~3);
  263. s03 = ((s1 << 16) >> 14);
  264. acc0 = *(mlib_f32*)((mlib_u8*)table0 + s00);
  265. acc1 = *(mlib_f32*)((mlib_u8*)table1 + s01);
  266. acc2 = *(mlib_f32*)((mlib_u8*)table2 + s02);
  267. acc3 = *(mlib_f32*)((mlib_u8*)table0 + s03);
  268. dp[0] = acc0;
  269. dp[1] = acc1;
  270. dp[2] = acc2;
  271. dp[3] = acc3;
  272. table = table0; table0 = table1;
  273. table1 = table2; table2 = table;
  274. dp += 4;
  275. i += 4;
  276. }
  277. sp = (mlib_s16*)sa;
  278. if ( i < xsize ) {
  279. *dp++ = table0[sp[0]];
  280. i++; sp++;
  281. }
  282. if ( i < xsize ) {
  283. *dp++ = table1[sp[0]];
  284. i++; sp++;
  285. }
  286. if ( i < xsize ) {
  287. *dp++ = table2[sp[0]];
  288. }
  289. }
  290. /***************************************************************/
  291. void mlib_v_ImageLookUp_S16_S32_3(const mlib_s16 *src,
  292. mlib_s32 slb,
  293. mlib_s32 *dst,
  294. mlib_s32 dlb,
  295. mlib_s32 xsize,
  296. mlib_s32 ysize,
  297. const mlib_s32 **table)
  298. {
  299. mlib_s16 *sl;
  300. mlib_s32 *dl;
  301. mlib_f32 *tab;
  302. mlib_s32 j;
  303. sl = (void *)src;
  304. dl = dst;
  305. /* row loop */
  306. for (j = 0; j < ysize; j ++) {
  307. mlib_s16 *sp = sl;
  308. mlib_f32 *dp = (mlib_f32*)dl;
  309. mlib_f32 *tab0 = (mlib_f32*)(&table[0][32768]);
  310. mlib_f32 *tab1 = (mlib_f32*)(&table[1][32768]);
  311. mlib_f32 *tab2 = (mlib_f32*)(&table[2][32768]);
  312. mlib_s32 off, size = xsize * 3;
  313. off = (mlib_s32)(((4 - ((mlib_addr)sp & 3)) & 3) >> 1);
  314. off = (off < size) ? off : size;
  315. if (off == 1) {
  316. *dp++ = tab0[(*sp++)];
  317. tab = tab0; tab0 = tab1;
  318. tab1 = tab2; tab2 = tab;
  319. size--;
  320. }
  321. if (size > 0) {
  322. mlib_v_ImageLookUp_S16_S32_3_D1(sp, dp, size, tab0, tab1, tab2);
  323. }
  324. sl = (mlib_s16 *) ((mlib_u8 *) sl + slb);
  325. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  326. }
  327. }
  328. /***************************************************************/