PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
C | 442 lines | 345 code | 61 blank | 36 comment | 38 complexity | dfaf4ad6d1c09b73ed747567aff12973 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_U8_S32_124_D1(const mlib_u8 *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_U8_S32_3_D1(const mlib_u8 *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_U8_S32_124_D1(const mlib_u8 *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_u32 *sa; /* aligned pointer to source data */
  52. mlib_u8 *sp; /* pointer to source data */
  53. mlib_u32 s0; /* 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_u32 s00, s01, s02, s03;
  59. sa = (mlib_u32 *) src;
  60. dp = dst;
  61. i = 0;
  62. if (xsize >= 4) {
  63. s0 = *sa++;
  64. s00 = (s0 >> 22) & 0x3FC;
  65. s01 = (s0 >> 14) & 0x3FC;
  66. #pragma pipeloop(0)
  67. for (i = 0; i <= xsize - 8; i += 4, dp += 4) {
  68. s02 = (s0 >> 6) & 0x3FC;
  69. s03 = (s0 << 2) & 0x3FC;
  70. acc0 = *(mlib_f32 *) ((mlib_u8 *) table0 + s00);
  71. acc1 = *(mlib_f32 *) ((mlib_u8 *) table1 + s01);
  72. acc2 = *(mlib_f32 *) ((mlib_u8 *) table2 + s02);
  73. acc3 = *(mlib_f32 *) ((mlib_u8 *) table3 + s03);
  74. s0 = *sa++;
  75. s00 = (s0 >> 22) & 0x3FC;
  76. s01 = (s0 >> 14) & 0x3FC;
  77. dp[0] = acc0;
  78. dp[1] = acc1;
  79. dp[2] = acc2;
  80. dp[3] = acc3;
  81. }
  82. s02 = (s0 >> 6) & 0x3FC;
  83. s03 = (s0 << 2) & 0x3FC;
  84. acc0 = *(mlib_f32 *) ((mlib_u8 *) table0 + s00);
  85. acc1 = *(mlib_f32 *) ((mlib_u8 *) table1 + s01);
  86. acc2 = *(mlib_f32 *) ((mlib_u8 *) table2 + s02);
  87. acc3 = *(mlib_f32 *) ((mlib_u8 *) table3 + s03);
  88. dp[0] = acc0;
  89. dp[1] = acc1;
  90. dp[2] = acc2;
  91. dp[3] = acc3;
  92. dp += 4;
  93. i += 4;
  94. }
  95. sp = (mlib_u8 *) sa;
  96. if (i < xsize) {
  97. *dp++ = table0[sp[0]];
  98. i++;
  99. sp++;
  100. }
  101. if (i < xsize) {
  102. *dp++ = table1[sp[0]];
  103. i++;
  104. sp++;
  105. }
  106. if (i < xsize) {
  107. *dp++ = table2[sp[0]];
  108. }
  109. }
  110. /***************************************************************/
  111. void mlib_v_ImageLookUp_U8_S32_1(const mlib_u8 *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_u8 *sl;
  120. mlib_s32 *dl;
  121. mlib_f32 *tab = (mlib_f32 *) table[0];
  122. mlib_s32 j, i;
  123. sl = (void *)src;
  124. dl = dst;
  125. /* row loop */
  126. for (j = 0; j < ysize; j++) {
  127. mlib_u8 *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);
  131. off = (off < size) ? off : size;
  132. for (i = 0; i < off; i++) {
  133. *dp++ = tab[(*sp++)];
  134. size--;
  135. }
  136. if (size > 0) {
  137. mlib_v_ImageLookUp_U8_S32_124_D1(sp, dp, size, tab, tab, tab, tab);
  138. }
  139. sl = (mlib_u8 *) ((mlib_u8 *) sl + slb);
  140. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  141. }
  142. }
  143. /***************************************************************/
  144. void mlib_v_ImageLookUp_U8_S32_2(const mlib_u8 *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_u8 *sl;
  153. mlib_s32 *dl;
  154. mlib_f32 *tab;
  155. mlib_s32 j, i;
  156. sl = (void *)src;
  157. dl = dst;
  158. /* row loop */
  159. for (j = 0; j < ysize; j++) {
  160. mlib_u8 *sp = sl;
  161. mlib_f32 *dp = (mlib_f32 *) dl;
  162. mlib_s32 off, size = xsize * 2;
  163. mlib_f32 *tab0 = (mlib_f32 *) table[0];
  164. mlib_f32 *tab1 = (mlib_f32 *) table[1];
  165. off = (mlib_s32) ((4 - ((mlib_addr) sp & 3)) & 3);
  166. off = (off < size) ? off : size;
  167. for (i = 0; i < off - 1; i += 2) {
  168. *dp++ = tab0[(*sp++)];
  169. *dp++ = tab1[(*sp++)];
  170. size -= 2;
  171. }
  172. if ((off & 1) != 0) {
  173. *dp++ = tab0[(*sp++)];
  174. size--;
  175. tab = tab0;
  176. tab0 = tab1;
  177. tab1 = tab;
  178. }
  179. if (size > 0) {
  180. mlib_v_ImageLookUp_U8_S32_124_D1(sp, dp, size, tab0, tab1, tab0, tab1);
  181. }
  182. sl = (mlib_u8 *) ((mlib_u8 *) sl + slb);
  183. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  184. }
  185. }
  186. /***************************************************************/
  187. void mlib_v_ImageLookUp_U8_S32_4(const mlib_u8 *src,
  188. mlib_s32 slb,
  189. mlib_s32 *dst,
  190. mlib_s32 dlb,
  191. mlib_s32 xsize,
  192. mlib_s32 ysize,
  193. const mlib_s32 **table)
  194. {
  195. mlib_u8 *sl;
  196. mlib_s32 *dl;
  197. mlib_f32 *tab;
  198. mlib_s32 j;
  199. sl = (void *)src;
  200. dl = dst;
  201. /* row loop */
  202. for (j = 0; j < ysize; j++) {
  203. mlib_u8 *sp = sl;
  204. mlib_f32 *dp = (mlib_f32 *) dl;
  205. mlib_f32 *tab0 = (mlib_f32 *) table[0];
  206. mlib_f32 *tab1 = (mlib_f32 *) table[1];
  207. mlib_f32 *tab2 = (mlib_f32 *) table[2];
  208. mlib_f32 *tab3 = (mlib_f32 *) table[3];
  209. mlib_s32 off, size = xsize * 4;
  210. off = (mlib_s32) ((4 - ((mlib_addr) sp & 3)) & 3);
  211. off = (off < size) ? off : size;
  212. if (off == 1) {
  213. *dp++ = tab0[(*sp++)];
  214. tab = tab0;
  215. tab0 = tab1;
  216. tab1 = tab2;
  217. tab2 = tab3;
  218. tab3 = tab;
  219. size--;
  220. }
  221. else if (off == 2) {
  222. *dp++ = tab0[(*sp++)];
  223. *dp++ = tab1[(*sp++)];
  224. tab = tab0;
  225. tab0 = tab2;
  226. tab2 = tab;
  227. tab = tab1;
  228. tab1 = tab3;
  229. tab3 = tab;
  230. size -= 2;
  231. }
  232. else if (off == 3) {
  233. *dp++ = tab0[(*sp++)];
  234. *dp++ = tab1[(*sp++)];
  235. *dp++ = tab2[(*sp++)];
  236. tab = tab3;
  237. tab3 = tab2;
  238. tab2 = tab1;
  239. tab1 = tab0;
  240. tab0 = tab;
  241. size -= 3;
  242. }
  243. if (size > 0) {
  244. mlib_v_ImageLookUp_U8_S32_124_D1(sp, dp, size, tab0, tab1, tab2, tab3);
  245. }
  246. sl = (mlib_u8 *) ((mlib_u8 *) sl + slb);
  247. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  248. }
  249. }
  250. /***************************************************************/
  251. void mlib_v_ImageLookUp_U8_S32_3_D1(const mlib_u8 *src,
  252. mlib_f32 *dst,
  253. mlib_s32 xsize,
  254. const mlib_f32 *table0,
  255. const mlib_f32 *table1,
  256. const mlib_f32 *table2)
  257. {
  258. mlib_u32 *sa; /* aligned pointer to source data */
  259. mlib_u8 *sp; /* pointer to source data */
  260. mlib_u32 s0; /* source data */
  261. mlib_f32 *dp; /* aligned pointer to destination */
  262. mlib_f32 acc0, acc1; /* destination data */
  263. mlib_f32 acc2, acc3; /* destination data */
  264. mlib_s32 i; /* loop variable */
  265. const mlib_f32 *table;
  266. mlib_u32 s00, s01, s02, s03;
  267. sa = (mlib_u32 *) src;
  268. dp = dst;
  269. i = 0;
  270. if (xsize >= 4) {
  271. s0 = *sa++;
  272. s00 = (s0 >> 22) & 0x3FC;
  273. s01 = (s0 >> 14) & 0x3FC;
  274. #pragma pipeloop(0)
  275. for (i = 0; i <= xsize - 8; i += 4, dp += 4) {
  276. s02 = (s0 >> 6) & 0x3FC;
  277. s03 = (s0 << 2) & 0x3FC;
  278. acc0 = *(mlib_f32 *) ((mlib_u8 *) table0 + s00);
  279. acc1 = *(mlib_f32 *) ((mlib_u8 *) table1 + s01);
  280. acc2 = *(mlib_f32 *) ((mlib_u8 *) table2 + s02);
  281. acc3 = *(mlib_f32 *) ((mlib_u8 *) table0 + s03);
  282. s0 = *sa++;
  283. s00 = (s0 >> 22) & 0x3FC;
  284. s01 = (s0 >> 14) & 0x3FC;
  285. table = table0;
  286. table0 = table1;
  287. table1 = table2;
  288. table2 = table;
  289. dp[0] = acc0;
  290. dp[1] = acc1;
  291. dp[2] = acc2;
  292. dp[3] = acc3;
  293. }
  294. s02 = (s0 >> 6) & 0x3FC;
  295. s03 = (s0 << 2) & 0x3FC;
  296. acc0 = *(mlib_f32 *) ((mlib_u8 *) table0 + s00);
  297. acc1 = *(mlib_f32 *) ((mlib_u8 *) table1 + s01);
  298. acc2 = *(mlib_f32 *) ((mlib_u8 *) table2 + s02);
  299. acc3 = *(mlib_f32 *) ((mlib_u8 *) table0 + s03);
  300. dp[0] = acc0;
  301. dp[1] = acc1;
  302. dp[2] = acc2;
  303. dp[3] = acc3;
  304. table = table0;
  305. table0 = table1;
  306. table1 = table2;
  307. table2 = table;
  308. dp += 4;
  309. i += 4;
  310. }
  311. sp = (mlib_u8 *) sa;
  312. if (i < xsize) {
  313. *dp++ = table0[sp[0]];
  314. i++;
  315. sp++;
  316. }
  317. if (i < xsize) {
  318. *dp++ = table1[sp[0]];
  319. i++;
  320. sp++;
  321. }
  322. if (i < xsize) {
  323. *dp++ = table2[sp[0]];
  324. }
  325. }
  326. /***************************************************************/
  327. void mlib_v_ImageLookUp_U8_S32_3(const mlib_u8 *src,
  328. mlib_s32 slb,
  329. mlib_s32 *dst,
  330. mlib_s32 dlb,
  331. mlib_s32 xsize,
  332. mlib_s32 ysize,
  333. const mlib_s32 **table)
  334. {
  335. mlib_u8 *sl;
  336. mlib_s32 *dl;
  337. mlib_f32 *tab;
  338. mlib_s32 j;
  339. sl = (void *)src;
  340. dl = dst;
  341. /* row loop */
  342. for (j = 0; j < ysize; j++) {
  343. mlib_u8 *sp = sl;
  344. mlib_f32 *dp = (mlib_f32 *) dl;
  345. mlib_f32 *tab0 = (mlib_f32 *) table[0];
  346. mlib_f32 *tab1 = (mlib_f32 *) table[1];
  347. mlib_f32 *tab2 = (mlib_f32 *) table[2];
  348. mlib_s32 off, size = xsize * 3;
  349. off = (mlib_s32) ((4 - ((mlib_addr) sp & 3)) & 3);
  350. off = (off < size) ? off : size;
  351. if (off == 1) {
  352. *dp++ = tab0[(*sp++)];
  353. tab = tab0;
  354. tab0 = tab1;
  355. tab1 = tab2;
  356. tab2 = tab;
  357. size--;
  358. }
  359. else if (off == 2) {
  360. *dp++ = tab0[(*sp++)];
  361. *dp++ = tab1[(*sp++)];
  362. tab = tab2;
  363. tab2 = tab1;
  364. tab1 = tab0;
  365. tab0 = tab;
  366. size -= 2;
  367. }
  368. else if (off == 3) {
  369. *dp++ = tab0[(*sp++)];
  370. *dp++ = tab1[(*sp++)];
  371. *dp++ = tab2[(*sp++)];
  372. size -= 3;
  373. }
  374. if (size > 0) {
  375. mlib_v_ImageLookUp_U8_S32_3_D1(sp, dp, size, tab0, tab1, tab2);
  376. }
  377. sl = (mlib_u8 *) ((mlib_u8 *) sl + slb);
  378. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  379. }
  380. }
  381. /***************************************************************/