jsimd.c 18 KB

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