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

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

#
C | 403 lines | 307 code | 60 blank | 36 comment | 26 complexity | ea468a1cf01f59a0ccc8314b42de80d6 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) 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_U16_S32_124_D1(const mlib_u16 *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_U16_S32_3_D1(const mlib_u16 *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_U16_S32_124_D1(const mlib_u16 *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_u16 *sp; /* pointer to source data */
  53. mlib_u32 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_u32 s00, s01, s02, s03;
  59. sa = (mlib_u32 *) 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_u16 *) sa;
  98. if (i < xsize) {
  99. *dp++ = table0[sp[0]];
  100. i++;
  101. sp++;
  102. }
  103. if (i < xsize) {
  104. *dp++ = table1[sp[0]];
  105. i++;
  106. sp++;
  107. }
  108. if (i < xsize) {
  109. *dp++ = table2[sp[0]];
  110. }
  111. }
  112. /***************************************************************/
  113. void mlib_v_ImageLookUp_U16_S32_1(const mlib_u16 *src,
  114. mlib_s32 slb,
  115. mlib_s32 *dst,
  116. mlib_s32 dlb,
  117. mlib_s32 xsize,
  118. mlib_s32 ysize,
  119. const mlib_s32 **table)
  120. {
  121. mlib_u16 *sl;
  122. mlib_s32 *dl;
  123. mlib_f32 *tab = (mlib_f32 *) (&table[0][0]);
  124. mlib_s32 j;
  125. sl = (void *)src;
  126. dl = dst;
  127. /* row loop */
  128. for (j = 0; j < ysize; j++) {
  129. mlib_u16 *sp = sl;
  130. mlib_f32 *dp = (mlib_f32 *) dl;
  131. mlib_s32 off, size = xsize;
  132. off = (mlib_s32) (((4 - ((mlib_addr) sp & 3)) & 3) >> 1);
  133. off = (off < size) ? off : size;
  134. if (off == 1) {
  135. *dp++ = tab[(*sp++)];
  136. size--;
  137. }
  138. if (size > 0) {
  139. mlib_v_ImageLookUp_U16_S32_124_D1(sp, dp, size, tab, tab, tab, tab);
  140. }
  141. sl = (mlib_u16 *) ((mlib_u8 *) sl + slb);
  142. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  143. }
  144. }
  145. /***************************************************************/
  146. void mlib_v_ImageLookUp_U16_S32_2(const mlib_u16 *src,
  147. mlib_s32 slb,
  148. mlib_s32 *dst,
  149. mlib_s32 dlb,
  150. mlib_s32 xsize,
  151. mlib_s32 ysize,
  152. const mlib_s32 **table)
  153. {
  154. mlib_u16 *sl;
  155. mlib_s32 *dl;
  156. mlib_f32 *tab;
  157. mlib_s32 j;
  158. sl = (void *)src;
  159. dl = dst;
  160. /* row loop */
  161. for (j = 0; j < ysize; j++) {
  162. mlib_u16 *sp = sl;
  163. mlib_f32 *dp = (mlib_f32 *) dl;
  164. mlib_s32 off, size = xsize * 2;
  165. mlib_f32 *tab0 = (mlib_f32 *) (&table[0][0]);
  166. mlib_f32 *tab1 = (mlib_f32 *) (&table[1][0]);
  167. off = (mlib_s32) (((4 - ((mlib_addr) sp & 3)) & 3) >> 1);
  168. off = (off < size) ? off : size;
  169. if ((off & 1) != 0) {
  170. *dp++ = tab0[(*sp++)];
  171. size--;
  172. tab = tab0;
  173. tab0 = tab1;
  174. tab1 = tab;
  175. }
  176. if (size > 0) {
  177. mlib_v_ImageLookUp_U16_S32_124_D1(sp, dp, size, tab0, tab1, tab0, tab1);
  178. }
  179. sl = (mlib_u16 *) ((mlib_u8 *) sl + slb);
  180. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  181. }
  182. }
  183. /***************************************************************/
  184. void mlib_v_ImageLookUp_U16_S32_4(const mlib_u16 *src,
  185. mlib_s32 slb,
  186. mlib_s32 *dst,
  187. mlib_s32 dlb,
  188. mlib_s32 xsize,
  189. mlib_s32 ysize,
  190. const mlib_s32 **table)
  191. {
  192. mlib_u16 *sl;
  193. mlib_s32 *dl;
  194. mlib_f32 *tab;
  195. mlib_s32 j;
  196. sl = (void *)src;
  197. dl = dst;
  198. /* row loop */
  199. for (j = 0; j < ysize; j++) {
  200. mlib_u16 *sp = sl;
  201. mlib_f32 *dp = (mlib_f32 *) dl;
  202. mlib_f32 *tab0 = (mlib_f32 *) (&table[0][0]);
  203. mlib_f32 *tab1 = (mlib_f32 *) (&table[1][0]);
  204. mlib_f32 *tab2 = (mlib_f32 *) (&table[2][0]);
  205. mlib_f32 *tab3 = (mlib_f32 *) (&table[3][0]);
  206. mlib_s32 off, size = xsize * 4;
  207. off = (mlib_s32) (((4 - ((mlib_addr) sp & 3)) & 3) >> 1);
  208. off = (off < size) ? off : size;
  209. if (off == 1) {
  210. *dp++ = tab0[(*sp++)];
  211. tab = tab0;
  212. tab0 = tab1;
  213. tab1 = tab2;
  214. tab2 = tab3;
  215. tab3 = tab;
  216. size--;
  217. }
  218. if (size > 0) {
  219. mlib_v_ImageLookUp_U16_S32_124_D1(sp, dp, size, tab0, tab1, tab2, tab3);
  220. }
  221. sl = (mlib_u16 *) ((mlib_u8 *) sl + slb);
  222. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  223. }
  224. }
  225. /***************************************************************/
  226. void mlib_v_ImageLookUp_U16_S32_3_D1(const mlib_u16 *src,
  227. mlib_f32 *dst,
  228. mlib_s32 xsize,
  229. const mlib_f32 *table0,
  230. const mlib_f32 *table1,
  231. const mlib_f32 *table2)
  232. {
  233. mlib_u32 *sa; /* aligned pointer to source data */
  234. mlib_u16 *sp; /* pointer to source data */
  235. mlib_u32 s0, s1; /* source data */
  236. mlib_f32 *dp; /* aligned pointer to destination */
  237. mlib_f32 acc0, acc1; /* destination data */
  238. mlib_f32 acc2, acc3; /* destination data */
  239. mlib_s32 i; /* loop variable */
  240. const mlib_f32 *table;
  241. mlib_u32 s00, s01, s02, s03;
  242. sa = (mlib_u32 *) src;
  243. dp = dst;
  244. i = 0;
  245. if (xsize >= 4) {
  246. s0 = *sa++;
  247. s1 = *sa++;
  248. s00 = (s0 >> 14) & (~3);
  249. s01 = ((s0 << 16) >> 14);
  250. #pragma pipeloop(0)
  251. for (i = 0; i <= xsize - 8; i += 4, dp += 4) {
  252. s02 = (s1 >> 14) & (~3);
  253. s03 = ((s1 << 16) >> 14);
  254. acc0 = *(mlib_f32 *) ((mlib_u8 *) table0 + s00);
  255. acc1 = *(mlib_f32 *) ((mlib_u8 *) table1 + s01);
  256. acc2 = *(mlib_f32 *) ((mlib_u8 *) table2 + s02);
  257. acc3 = *(mlib_f32 *) ((mlib_u8 *) table0 + s03);
  258. s0 = *sa++;
  259. s1 = *sa++;
  260. s00 = (s0 >> 14) & (~3);
  261. s01 = ((s0 << 16) >> 14);
  262. table = table0;
  263. table0 = table1;
  264. table1 = table2;
  265. table2 = table;
  266. dp[0] = acc0;
  267. dp[1] = acc1;
  268. dp[2] = acc2;
  269. dp[3] = acc3;
  270. }
  271. s02 = (s1 >> 14) & (~3);
  272. s03 = ((s1 << 16) >> 14);
  273. acc0 = *(mlib_f32 *) ((mlib_u8 *) table0 + s00);
  274. acc1 = *(mlib_f32 *) ((mlib_u8 *) table1 + s01);
  275. acc2 = *(mlib_f32 *) ((mlib_u8 *) table2 + s02);
  276. acc3 = *(mlib_f32 *) ((mlib_u8 *) table0 + s03);
  277. dp[0] = acc0;
  278. dp[1] = acc1;
  279. dp[2] = acc2;
  280. dp[3] = acc3;
  281. table = table0;
  282. table0 = table1;
  283. table1 = table2;
  284. table2 = table;
  285. dp += 4;
  286. i += 4;
  287. }
  288. sp = (mlib_u16 *) sa;
  289. if (i < xsize) {
  290. *dp++ = table0[sp[0]];
  291. i++;
  292. sp++;
  293. }
  294. if (i < xsize) {
  295. *dp++ = table1[sp[0]];
  296. i++;
  297. sp++;
  298. }
  299. if (i < xsize) {
  300. *dp++ = table2[sp[0]];
  301. }
  302. }
  303. /***************************************************************/
  304. void mlib_v_ImageLookUp_U16_S32_3(const mlib_u16 *src,
  305. mlib_s32 slb,
  306. mlib_s32 *dst,
  307. mlib_s32 dlb,
  308. mlib_s32 xsize,
  309. mlib_s32 ysize,
  310. const mlib_s32 **table)
  311. {
  312. mlib_u16 *sl;
  313. mlib_s32 *dl;
  314. mlib_f32 *tab;
  315. mlib_s32 j;
  316. sl = (void *)src;
  317. dl = dst;
  318. /* row loop */
  319. for (j = 0; j < ysize; j++) {
  320. mlib_u16 *sp = sl;
  321. mlib_f32 *dp = (mlib_f32 *) dl;
  322. mlib_f32 *tab0 = (mlib_f32 *) (&table[0][0]);
  323. mlib_f32 *tab1 = (mlib_f32 *) (&table[1][0]);
  324. mlib_f32 *tab2 = (mlib_f32 *) (&table[2][0]);
  325. mlib_s32 off, size = xsize * 3;
  326. off = (mlib_s32) (((4 - ((mlib_addr) sp & 3)) & 3) >> 1);
  327. off = (off < size) ? off : size;
  328. if (off == 1) {
  329. *dp++ = tab0[(*sp++)];
  330. tab = tab0;
  331. tab0 = tab1;
  332. tab1 = tab2;
  333. tab2 = tab;
  334. size--;
  335. }
  336. if (size > 0) {
  337. mlib_v_ImageLookUp_U16_S32_3_D1(sp, dp, size, tab0, tab1, tab2);
  338. }
  339. sl = (mlib_u16 *) ((mlib_u8 *) sl + slb);
  340. dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb);
  341. }
  342. }
  343. /***************************************************************/