jsimd_arm64.c 17 KB

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