jsimd_powerpc.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. /*
  2. * jsimd_powerpc.c
  3. *
  4. * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
  5. * Copyright (C) 2009-2011, 2014-2016, D. R. Commander.
  6. * Copyright (C) 2015, Matthieu Darbois.
  7. *
  8. * Based on the x86 SIMD extension for IJG JPEG library,
  9. * Copyright (C) 1999-2006, MIYASAKA Masaru.
  10. * For conditions of distribution and use, see copyright notice in jsimdext.inc
  11. *
  12. * This file contains the interface between the "normal" portions
  13. * of the library and the SIMD implementations when running on a
  14. * PowerPC architecture.
  15. */
  16. #define JPEG_INTERNALS
  17. #include "../jinclude.h"
  18. #include "../jpeglib.h"
  19. #include "../jsimd.h"
  20. #include "../jdct.h"
  21. #include "../jsimddct.h"
  22. #include "jsimd.h"
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <ctype.h>
  26. static unsigned int simd_support = ~0;
  27. #if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
  28. #define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024)
  29. LOCAL(int)
  30. check_feature (char *buffer, char *feature)
  31. {
  32. char *p;
  33. if (*feature == 0)
  34. return 0;
  35. if (strncmp(buffer, "cpu", 3) != 0)
  36. return 0;
  37. buffer += 3;
  38. while (isspace(*buffer))
  39. buffer++;
  40. /* Check if 'feature' is present in the buffer as a separate word */
  41. while ((p = strstr(buffer, feature))) {
  42. if (p > buffer && !isspace(*(p - 1))) {
  43. buffer++;
  44. continue;
  45. }
  46. p += strlen(feature);
  47. if (*p != 0 && !isspace(*p)) {
  48. buffer++;
  49. continue;
  50. }
  51. return 1;
  52. }
  53. return 0;
  54. }
  55. LOCAL(int)
  56. parse_proc_cpuinfo (int bufsize)
  57. {
  58. char *buffer = (char *)malloc(bufsize);
  59. FILE *fd;
  60. simd_support = 0;
  61. if (!buffer)
  62. return 0;
  63. fd = fopen("/proc/cpuinfo", "r");
  64. if (fd) {
  65. while (fgets(buffer, bufsize, fd)) {
  66. if (!strchr(buffer, '\n') && !feof(fd)) {
  67. /* "impossible" happened - insufficient size of the buffer! */
  68. fclose(fd);
  69. free(buffer);
  70. return 0;
  71. }
  72. if (check_feature(buffer, "altivec"))
  73. simd_support |= JSIMD_ALTIVEC;
  74. }
  75. fclose(fd);
  76. }
  77. free(buffer);
  78. return 1;
  79. }
  80. #endif
  81. /*
  82. * Check what SIMD accelerations are supported.
  83. *
  84. * FIXME: This code is racy under a multi-threaded environment.
  85. */
  86. LOCAL(void)
  87. init_simd (void)
  88. {
  89. char *env = NULL;
  90. #if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__))
  91. int bufsize = 1024; /* an initial guess for the line buffer size limit */
  92. #endif
  93. if (simd_support != ~0U)
  94. return;
  95. simd_support = 0;
  96. #if defined(__ALTIVEC__) || defined(__APPLE__)
  97. simd_support |= JSIMD_ALTIVEC;
  98. #elif defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
  99. while (!parse_proc_cpuinfo(bufsize)) {
  100. bufsize *= 2;
  101. if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
  102. break;
  103. }
  104. #endif
  105. /* Force different settings through environment variables */
  106. env = getenv("JSIMD_FORCEALTIVEC");
  107. if ((env != NULL) && (strcmp(env, "1") == 0))
  108. simd_support = JSIMD_ALTIVEC;
  109. env = getenv("JSIMD_FORCENONE");
  110. if ((env != NULL) && (strcmp(env, "1") == 0))
  111. simd_support = 0;
  112. }
  113. GLOBAL(int)
  114. jsimd_can_rgb_ycc (void)
  115. {
  116. init_simd();
  117. /* The code is optimised for these values only */
  118. if (BITS_IN_JSAMPLE != 8)
  119. return 0;
  120. if (sizeof(JDIMENSION) != 4)
  121. return 0;
  122. if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  123. return 0;
  124. if (simd_support & JSIMD_ALTIVEC)
  125. return 1;
  126. return 0;
  127. }
  128. GLOBAL(int)
  129. jsimd_can_rgb_gray (void)
  130. {
  131. init_simd();
  132. /* The code is optimised for these values only */
  133. if (BITS_IN_JSAMPLE != 8)
  134. return 0;
  135. if (sizeof(JDIMENSION) != 4)
  136. return 0;
  137. if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  138. return 0;
  139. if (simd_support & JSIMD_ALTIVEC)
  140. return 1;
  141. return 0;
  142. }
  143. GLOBAL(int)
  144. jsimd_can_ycc_rgb (void)
  145. {
  146. init_simd();
  147. /* The code is optimised for these values only */
  148. if (BITS_IN_JSAMPLE != 8)
  149. return 0;
  150. if (sizeof(JDIMENSION) != 4)
  151. return 0;
  152. if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
  153. return 0;
  154. if (simd_support & JSIMD_ALTIVEC)
  155. return 1;
  156. return 0;
  157. }
  158. GLOBAL(int)
  159. jsimd_can_ycc_rgb565 (void)
  160. {
  161. return 0;
  162. }
  163. GLOBAL(void)
  164. jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
  165. JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
  166. JDIMENSION output_row, int num_rows)
  167. {
  168. void (*altivecfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
  169. switch(cinfo->in_color_space) {
  170. case JCS_EXT_RGB:
  171. altivecfct=jsimd_extrgb_ycc_convert_altivec;
  172. break;
  173. case JCS_EXT_RGBX:
  174. case JCS_EXT_RGBA:
  175. altivecfct=jsimd_extrgbx_ycc_convert_altivec;
  176. break;
  177. case JCS_EXT_BGR:
  178. altivecfct=jsimd_extbgr_ycc_convert_altivec;
  179. break;
  180. case JCS_EXT_BGRX:
  181. case JCS_EXT_BGRA:
  182. altivecfct=jsimd_extbgrx_ycc_convert_altivec;
  183. break;
  184. case JCS_EXT_XBGR:
  185. case JCS_EXT_ABGR:
  186. altivecfct=jsimd_extxbgr_ycc_convert_altivec;
  187. break;
  188. case JCS_EXT_XRGB:
  189. case JCS_EXT_ARGB:
  190. altivecfct=jsimd_extxrgb_ycc_convert_altivec;
  191. break;
  192. default:
  193. altivecfct=jsimd_rgb_ycc_convert_altivec;
  194. break;
  195. }
  196. altivecfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
  197. }
  198. GLOBAL(void)
  199. jsimd_rgb_gray_convert (j_compress_ptr cinfo,
  200. JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
  201. JDIMENSION output_row, int num_rows)
  202. {
  203. void (*altivecfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
  204. switch(cinfo->in_color_space) {
  205. case JCS_EXT_RGB:
  206. altivecfct=jsimd_extrgb_gray_convert_altivec;
  207. break;
  208. case JCS_EXT_RGBX:
  209. case JCS_EXT_RGBA:
  210. altivecfct=jsimd_extrgbx_gray_convert_altivec;
  211. break;
  212. case JCS_EXT_BGR:
  213. altivecfct=jsimd_extbgr_gray_convert_altivec;
  214. break;
  215. case JCS_EXT_BGRX:
  216. case JCS_EXT_BGRA:
  217. altivecfct=jsimd_extbgrx_gray_convert_altivec;
  218. break;
  219. case JCS_EXT_XBGR:
  220. case JCS_EXT_ABGR:
  221. altivecfct=jsimd_extxbgr_gray_convert_altivec;
  222. break;
  223. case JCS_EXT_XRGB:
  224. case JCS_EXT_ARGB:
  225. altivecfct=jsimd_extxrgb_gray_convert_altivec;
  226. break;
  227. default:
  228. altivecfct=jsimd_rgb_gray_convert_altivec;
  229. break;
  230. }
  231. altivecfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
  232. }
  233. GLOBAL(void)
  234. jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
  235. JSAMPIMAGE input_buf, JDIMENSION input_row,
  236. JSAMPARRAY output_buf, int num_rows)
  237. {
  238. void (*altivecfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
  239. switch(cinfo->out_color_space) {
  240. case JCS_EXT_RGB:
  241. altivecfct=jsimd_ycc_extrgb_convert_altivec;
  242. break;
  243. case JCS_EXT_RGBX:
  244. case JCS_EXT_RGBA:
  245. altivecfct=jsimd_ycc_extrgbx_convert_altivec;
  246. break;
  247. case JCS_EXT_BGR:
  248. altivecfct=jsimd_ycc_extbgr_convert_altivec;
  249. break;
  250. case JCS_EXT_BGRX:
  251. case JCS_EXT_BGRA:
  252. altivecfct=jsimd_ycc_extbgrx_convert_altivec;
  253. break;
  254. case JCS_EXT_XBGR:
  255. case JCS_EXT_ABGR:
  256. altivecfct=jsimd_ycc_extxbgr_convert_altivec;
  257. break;
  258. case JCS_EXT_XRGB:
  259. case JCS_EXT_ARGB:
  260. altivecfct=jsimd_ycc_extxrgb_convert_altivec;
  261. break;
  262. default:
  263. altivecfct=jsimd_ycc_rgb_convert_altivec;
  264. break;
  265. }
  266. altivecfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
  267. }
  268. GLOBAL(void)
  269. jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
  270. JSAMPIMAGE input_buf, JDIMENSION input_row,
  271. JSAMPARRAY output_buf, int num_rows)
  272. {
  273. }
  274. GLOBAL(int)
  275. jsimd_can_h2v2_downsample (void)
  276. {
  277. init_simd();
  278. /* The code is optimised for these values only */
  279. if (BITS_IN_JSAMPLE != 8)
  280. return 0;
  281. if (sizeof(JDIMENSION) != 4)
  282. return 0;
  283. if (simd_support & JSIMD_ALTIVEC)
  284. return 1;
  285. return 0;
  286. }
  287. GLOBAL(int)
  288. jsimd_can_h2v1_downsample (void)
  289. {
  290. init_simd();
  291. /* The code is optimised for these values only */
  292. if (BITS_IN_JSAMPLE != 8)
  293. return 0;
  294. if (sizeof(JDIMENSION) != 4)
  295. return 0;
  296. if (simd_support & JSIMD_ALTIVEC)
  297. return 1;
  298. return 0;
  299. }
  300. GLOBAL(void)
  301. jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
  302. JSAMPARRAY input_data, JSAMPARRAY output_data)
  303. {
  304. jsimd_h2v2_downsample_altivec(cinfo->image_width, cinfo->max_v_samp_factor,
  305. compptr->v_samp_factor,
  306. compptr->width_in_blocks,
  307. input_data, output_data);
  308. }
  309. GLOBAL(void)
  310. jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
  311. JSAMPARRAY input_data, JSAMPARRAY output_data)
  312. {
  313. jsimd_h2v1_downsample_altivec(cinfo->image_width, cinfo->max_v_samp_factor,
  314. compptr->v_samp_factor,
  315. compptr->width_in_blocks,
  316. input_data, output_data);
  317. }
  318. GLOBAL(int)
  319. jsimd_can_h2v2_upsample (void)
  320. {
  321. init_simd();
  322. /* The code is optimised for these values only */
  323. if (BITS_IN_JSAMPLE != 8)
  324. return 0;
  325. if (sizeof(JDIMENSION) != 4)
  326. return 0;
  327. if (simd_support & JSIMD_ALTIVEC)
  328. return 1;
  329. return 0;
  330. }
  331. GLOBAL(int)
  332. jsimd_can_h2v1_upsample (void)
  333. {
  334. init_simd();
  335. /* The code is optimised for these values only */
  336. if (BITS_IN_JSAMPLE != 8)
  337. return 0;
  338. if (sizeof(JDIMENSION) != 4)
  339. return 0;
  340. if (simd_support & JSIMD_ALTIVEC)
  341. return 1;
  342. return 0;
  343. }
  344. GLOBAL(void)
  345. jsimd_h2v2_upsample (j_decompress_ptr cinfo,
  346. jpeg_component_info *compptr,
  347. JSAMPARRAY input_data,
  348. JSAMPARRAY *output_data_ptr)
  349. {
  350. jsimd_h2v2_upsample_altivec(cinfo->max_v_samp_factor, cinfo->output_width,
  351. input_data, output_data_ptr);
  352. }
  353. GLOBAL(void)
  354. jsimd_h2v1_upsample (j_decompress_ptr cinfo,
  355. jpeg_component_info *compptr,
  356. JSAMPARRAY input_data,
  357. JSAMPARRAY *output_data_ptr)
  358. {
  359. jsimd_h2v1_upsample_altivec(cinfo->max_v_samp_factor, cinfo->output_width,
  360. input_data, output_data_ptr);
  361. }
  362. GLOBAL(int)
  363. jsimd_can_h2v2_fancy_upsample (void)
  364. {
  365. init_simd();
  366. /* The code is optimised for these values only */
  367. if (BITS_IN_JSAMPLE != 8)
  368. return 0;
  369. if (sizeof(JDIMENSION) != 4)
  370. return 0;
  371. if (simd_support & JSIMD_ALTIVEC)
  372. return 1;
  373. return 0;
  374. }
  375. GLOBAL(int)
  376. jsimd_can_h2v1_fancy_upsample (void)
  377. {
  378. init_simd();
  379. /* The code is optimised for these values only */
  380. if (BITS_IN_JSAMPLE != 8)
  381. return 0;
  382. if (sizeof(JDIMENSION) != 4)
  383. return 0;
  384. if (simd_support & JSIMD_ALTIVEC)
  385. return 1;
  386. return 0;
  387. }
  388. GLOBAL(void)
  389. jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
  390. jpeg_component_info *compptr,
  391. JSAMPARRAY input_data,
  392. JSAMPARRAY *output_data_ptr)
  393. {
  394. jsimd_h2v2_fancy_upsample_altivec(cinfo->max_v_samp_factor,
  395. compptr->downsampled_width, input_data,
  396. output_data_ptr);
  397. }
  398. GLOBAL(void)
  399. jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
  400. jpeg_component_info *compptr,
  401. JSAMPARRAY input_data,
  402. JSAMPARRAY *output_data_ptr)
  403. {
  404. jsimd_h2v1_fancy_upsample_altivec(cinfo->max_v_samp_factor,
  405. compptr->downsampled_width, input_data,
  406. output_data_ptr);
  407. }
  408. GLOBAL(int)
  409. jsimd_can_h2v2_merged_upsample (void)
  410. {
  411. init_simd();
  412. /* The code is optimised for these values only */
  413. if (BITS_IN_JSAMPLE != 8)
  414. return 0;
  415. if (sizeof(JDIMENSION) != 4)
  416. return 0;
  417. if (simd_support & JSIMD_ALTIVEC)
  418. return 1;
  419. return 0;
  420. }
  421. GLOBAL(int)
  422. jsimd_can_h2v1_merged_upsample (void)
  423. {
  424. init_simd();
  425. /* The code is optimised for these values only */
  426. if (BITS_IN_JSAMPLE != 8)
  427. return 0;
  428. if (sizeof(JDIMENSION) != 4)
  429. return 0;
  430. if (simd_support & JSIMD_ALTIVEC)
  431. return 1;
  432. return 0;
  433. }
  434. GLOBAL(void)
  435. jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
  436. JSAMPIMAGE input_buf,
  437. JDIMENSION in_row_group_ctr,
  438. JSAMPARRAY output_buf)
  439. {
  440. void (*altivecfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
  441. switch(cinfo->out_color_space) {
  442. case JCS_EXT_RGB:
  443. altivecfct=jsimd_h2v2_extrgb_merged_upsample_altivec;
  444. break;
  445. case JCS_EXT_RGBX:
  446. case JCS_EXT_RGBA:
  447. altivecfct=jsimd_h2v2_extrgbx_merged_upsample_altivec;
  448. break;
  449. case JCS_EXT_BGR:
  450. altivecfct=jsimd_h2v2_extbgr_merged_upsample_altivec;
  451. break;
  452. case JCS_EXT_BGRX:
  453. case JCS_EXT_BGRA:
  454. altivecfct=jsimd_h2v2_extbgrx_merged_upsample_altivec;
  455. break;
  456. case JCS_EXT_XBGR:
  457. case JCS_EXT_ABGR:
  458. altivecfct=jsimd_h2v2_extxbgr_merged_upsample_altivec;
  459. break;
  460. case JCS_EXT_XRGB:
  461. case JCS_EXT_ARGB:
  462. altivecfct=jsimd_h2v2_extxrgb_merged_upsample_altivec;
  463. break;
  464. default:
  465. altivecfct=jsimd_h2v2_merged_upsample_altivec;
  466. break;
  467. }
  468. altivecfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
  469. }
  470. GLOBAL(void)
  471. jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
  472. JSAMPIMAGE input_buf,
  473. JDIMENSION in_row_group_ctr,
  474. JSAMPARRAY output_buf)
  475. {
  476. void (*altivecfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
  477. switch(cinfo->out_color_space) {
  478. case JCS_EXT_RGB:
  479. altivecfct=jsimd_h2v1_extrgb_merged_upsample_altivec;
  480. break;
  481. case JCS_EXT_RGBX:
  482. case JCS_EXT_RGBA:
  483. altivecfct=jsimd_h2v1_extrgbx_merged_upsample_altivec;
  484. break;
  485. case JCS_EXT_BGR:
  486. altivecfct=jsimd_h2v1_extbgr_merged_upsample_altivec;
  487. break;
  488. case JCS_EXT_BGRX:
  489. case JCS_EXT_BGRA:
  490. altivecfct=jsimd_h2v1_extbgrx_merged_upsample_altivec;
  491. break;
  492. case JCS_EXT_XBGR:
  493. case JCS_EXT_ABGR:
  494. altivecfct=jsimd_h2v1_extxbgr_merged_upsample_altivec;
  495. break;
  496. case JCS_EXT_XRGB:
  497. case JCS_EXT_ARGB:
  498. altivecfct=jsimd_h2v1_extxrgb_merged_upsample_altivec;
  499. break;
  500. default:
  501. altivecfct=jsimd_h2v1_merged_upsample_altivec;
  502. break;
  503. }
  504. altivecfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
  505. }
  506. GLOBAL(int)
  507. jsimd_can_convsamp (void)
  508. {
  509. init_simd();
  510. /* The code is optimised for these values only */
  511. if (DCTSIZE != 8)
  512. return 0;
  513. if (BITS_IN_JSAMPLE != 8)
  514. return 0;
  515. if (sizeof(JDIMENSION) != 4)
  516. return 0;
  517. if (sizeof(DCTELEM) != 2)
  518. return 0;
  519. if (simd_support & JSIMD_ALTIVEC)
  520. return 1;
  521. return 0;
  522. }
  523. GLOBAL(int)
  524. jsimd_can_convsamp_float (void)
  525. {
  526. return 0;
  527. }
  528. GLOBAL(void)
  529. jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
  530. DCTELEM *workspace)
  531. {
  532. jsimd_convsamp_altivec(sample_data, start_col, workspace);
  533. }
  534. GLOBAL(void)
  535. jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
  536. FAST_FLOAT *workspace)
  537. {
  538. }
  539. GLOBAL(int)
  540. jsimd_can_fdct_islow (void)
  541. {
  542. init_simd();
  543. /* The code is optimised for these values only */
  544. if (DCTSIZE != 8)
  545. return 0;
  546. if (sizeof(DCTELEM) != 2)
  547. return 0;
  548. if (simd_support & JSIMD_ALTIVEC)
  549. return 1;
  550. return 0;
  551. }
  552. GLOBAL(int)
  553. jsimd_can_fdct_ifast (void)
  554. {
  555. init_simd();
  556. /* The code is optimised for these values only */
  557. if (DCTSIZE != 8)
  558. return 0;
  559. if (sizeof(DCTELEM) != 2)
  560. return 0;
  561. if (simd_support & JSIMD_ALTIVEC)
  562. return 1;
  563. return 0;
  564. }
  565. GLOBAL(int)
  566. jsimd_can_fdct_float (void)
  567. {
  568. return 0;
  569. }
  570. GLOBAL(void)
  571. jsimd_fdct_islow (DCTELEM *data)
  572. {
  573. jsimd_fdct_islow_altivec(data);
  574. }
  575. GLOBAL(void)
  576. jsimd_fdct_ifast (DCTELEM *data)
  577. {
  578. jsimd_fdct_ifast_altivec(data);
  579. }
  580. GLOBAL(void)
  581. jsimd_fdct_float (FAST_FLOAT *data)
  582. {
  583. }
  584. GLOBAL(int)
  585. jsimd_can_quantize (void)
  586. {
  587. init_simd();
  588. /* The code is optimised for these values only */
  589. if (DCTSIZE != 8)
  590. return 0;
  591. if (sizeof(JCOEF) != 2)
  592. return 0;
  593. if (sizeof(DCTELEM) != 2)
  594. return 0;
  595. if (simd_support & JSIMD_ALTIVEC)
  596. return 1;
  597. return 0;
  598. }
  599. GLOBAL(int)
  600. jsimd_can_quantize_float (void)
  601. {
  602. return 0;
  603. }
  604. GLOBAL(void)
  605. jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
  606. DCTELEM *workspace)
  607. {
  608. jsimd_quantize_altivec(coef_block, divisors, workspace);
  609. }
  610. GLOBAL(void)
  611. jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
  612. FAST_FLOAT *workspace)
  613. {
  614. }
  615. GLOBAL(int)
  616. jsimd_can_idct_2x2 (void)
  617. {
  618. return 0;
  619. }
  620. GLOBAL(int)
  621. jsimd_can_idct_4x4 (void)
  622. {
  623. return 0;
  624. }
  625. GLOBAL(void)
  626. jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
  627. JCOEFPTR coef_block, JSAMPARRAY output_buf,
  628. JDIMENSION output_col)
  629. {
  630. }
  631. GLOBAL(void)
  632. jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
  633. JCOEFPTR coef_block, JSAMPARRAY output_buf,
  634. JDIMENSION output_col)
  635. {
  636. }
  637. GLOBAL(int)
  638. jsimd_can_idct_islow (void)
  639. {
  640. init_simd();
  641. /* The code is optimised for these values only */
  642. if (DCTSIZE != 8)
  643. return 0;
  644. if (sizeof(JCOEF) != 2)
  645. return 0;
  646. if (simd_support & JSIMD_ALTIVEC)
  647. return 1;
  648. return 0;
  649. }
  650. GLOBAL(int)
  651. jsimd_can_idct_ifast (void)
  652. {
  653. init_simd();
  654. /* The code is optimised for these values only */
  655. if (DCTSIZE != 8)
  656. return 0;
  657. if (sizeof(JCOEF) != 2)
  658. return 0;
  659. if (simd_support & JSIMD_ALTIVEC)
  660. return 1;
  661. return 0;
  662. }
  663. GLOBAL(int)
  664. jsimd_can_idct_float (void)
  665. {
  666. return 0;
  667. }
  668. GLOBAL(void)
  669. jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
  670. JCOEFPTR coef_block, JSAMPARRAY output_buf,
  671. JDIMENSION output_col)
  672. {
  673. jsimd_idct_islow_altivec(compptr->dct_table, coef_block, output_buf,
  674. output_col);
  675. }
  676. GLOBAL(void)
  677. jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
  678. JCOEFPTR coef_block, JSAMPARRAY output_buf,
  679. JDIMENSION output_col)
  680. {
  681. jsimd_idct_ifast_altivec(compptr->dct_table, coef_block, output_buf,
  682. output_col);
  683. }
  684. GLOBAL(void)
  685. jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
  686. JCOEFPTR coef_block, JSAMPARRAY output_buf,
  687. JDIMENSION output_col)
  688. {
  689. }
  690. GLOBAL(int)
  691. jsimd_can_huff_encode_one_block (void)
  692. {
  693. return 0;
  694. }
  695. GLOBAL(JOCTET*)
  696. jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
  697. int last_dc_val, c_derived_tbl *dctbl,
  698. c_derived_tbl *actbl)
  699. {
  700. return NULL;
  701. }