jsimd.c 19 KB

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