blob: ea621da89874d1b84762e50f69604f718ffd4bed [file] [log] [blame]
DRC321e0682011-05-03 08:47:43 +00001/*
2 * jsimd_arm.c
3 *
4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
DRC499c4702016-01-13 03:13:20 -06005 * Copyright 2009-2011, 2013-2014, 2016 D. R. Commander
6 * Copyright 2015-2016 Matthieu Darbois
DRCe189ec72014-02-06 19:15:03 +00007 *
DRC321e0682011-05-03 08:47:43 +00008 * 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
DRC14198522014-05-15 19:45:11 +000013 * of the library and the SIMD implementations when running on a
14 * 32-bit ARM architecture.
DRC321e0682011-05-03 08:47:43 +000015 */
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
25#include <stdio.h>
26#include <string.h>
27#include <ctype.h>
28
29static unsigned int simd_support = ~0;
DRCe8aa5fa2016-01-15 13:15:54 -060030static unsigned int simd_huffman = 1;
DRC321e0682011-05-03 08:47:43 +000031
DRC4346f912011-06-14 22:16:50 +000032#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
DRC321e0682011-05-03 08:47:43 +000033
34#define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024)
35
36LOCAL(int)
37check_feature (char *buffer, char *feature)
38{
39 char *p;
40 if (*feature == 0)
41 return 0;
42 if (strncmp(buffer, "Features", 8) != 0)
43 return 0;
44 buffer += 8;
45 while (isspace(*buffer))
46 buffer++;
47
48 /* Check if 'feature' is present in the buffer as a separate word */
49 while ((p = strstr(buffer, feature))) {
50 if (p > buffer && !isspace(*(p - 1))) {
51 buffer++;
52 continue;
53 }
54 p += strlen(feature);
55 if (*p != 0 && !isspace(*p)) {
56 buffer++;
57 continue;
58 }
59 return 1;
60 }
61 return 0;
62}
63
64LOCAL(int)
65parse_proc_cpuinfo (int bufsize)
66{
67 char *buffer = (char *)malloc(bufsize);
68 FILE *fd;
69 simd_support = 0;
70
71 if (!buffer)
72 return 0;
73
74 fd = fopen("/proc/cpuinfo", "r");
75 if (fd) {
76 while (fgets(buffer, bufsize, fd)) {
77 if (!strchr(buffer, '\n') && !feof(fd)) {
78 /* "impossible" happened - insufficient size of the buffer! */
79 fclose(fd);
80 free(buffer);
81 return 0;
82 }
83 if (check_feature(buffer, "neon"))
84 simd_support |= JSIMD_ARM_NEON;
85 }
86 fclose(fd);
87 }
88 free(buffer);
89 return 1;
90}
91
92#endif
93
94/*
95 * Check what SIMD accelerations are supported.
96 *
97 * FIXME: This code is racy under a multi-threaded environment.
98 */
99LOCAL(void)
100init_simd (void)
101{
102 char *env = NULL;
DRC4346f912011-06-14 22:16:50 +0000103#if !defined(__ARM_NEON__) && defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
DRC321e0682011-05-03 08:47:43 +0000104 int bufsize = 1024; /* an initial guess for the line buffer size limit */
DRC4346f912011-06-14 22:16:50 +0000105#endif
DRC321e0682011-05-03 08:47:43 +0000106
DRCd65d99a2012-01-31 03:39:23 +0000107 if (simd_support != ~0U)
DRC321e0682011-05-03 08:47:43 +0000108 return;
109
110 simd_support = 0;
111
DRC4346f912011-06-14 22:16:50 +0000112#if defined(__ARM_NEON__)
113 simd_support |= JSIMD_ARM_NEON;
114#elif defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
115 /* We still have a chance to use NEON regardless of globally used
116 * -mcpu/-mfpu options passed to gcc by performing runtime detection via
117 * /proc/cpuinfo parsing on linux/android */
DRC321e0682011-05-03 08:47:43 +0000118 while (!parse_proc_cpuinfo(bufsize)) {
119 bufsize *= 2;
120 if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
121 break;
122 }
123#endif
124
125 /* Force different settings through environment variables */
DRC19eeaa72013-10-31 07:40:24 +0000126 env = getenv("JSIMD_FORCENEON");
DRC321e0682011-05-03 08:47:43 +0000127 if ((env != NULL) && (strcmp(env, "1") == 0))
128 simd_support &= JSIMD_ARM_NEON;
DRC19eeaa72013-10-31 07:40:24 +0000129 env = getenv("JSIMD_FORCENONE");
DRC321e0682011-05-03 08:47:43 +0000130 if ((env != NULL) && (strcmp(env, "1") == 0))
131 simd_support = 0;
DRCe8aa5fa2016-01-15 13:15:54 -0600132 env = getenv("JSIMD_NOHUFFENC");
133 if ((env != NULL) && (strcmp(env, "1") == 0))
134 simd_huffman = 0;
DRC321e0682011-05-03 08:47:43 +0000135}
136
137GLOBAL(int)
138jsimd_can_rgb_ycc (void)
139{
140 init_simd();
141
DRC7a9376c2011-08-12 19:27:20 +0000142 /* The code is optimised for these values only */
143 if (BITS_IN_JSAMPLE != 8)
144 return 0;
145 if (sizeof(JDIMENSION) != 4)
146 return 0;
147 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
148 return 0;
149
150 if (simd_support & JSIMD_ARM_NEON)
151 return 1;
152
DRC321e0682011-05-03 08:47:43 +0000153 return 0;
154}
155
156GLOBAL(int)
157jsimd_can_rgb_gray (void)
158{
159 init_simd();
160
161 return 0;
162}
163
164GLOBAL(int)
165jsimd_can_ycc_rgb (void)
166{
167 init_simd();
168
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;
DRC14198522014-05-15 19:45:11 +0000176
DRC321e0682011-05-03 08:47:43 +0000177 if (simd_support & JSIMD_ARM_NEON)
178 return 1;
179
180 return 0;
181}
182
DRCd729f4d2014-08-23 15:47:51 +0000183GLOBAL(int)
184jsimd_can_ycc_rgb565 (void)
185{
186 init_simd();
187
188 /* The code is optimised for these values only */
189 if (BITS_IN_JSAMPLE != 8)
190 return 0;
191 if (sizeof(JDIMENSION) != 4)
192 return 0;
193
194 if (simd_support & JSIMD_ARM_NEON)
195 return 1;
196
197 return 0;
198}
199
DRC321e0682011-05-03 08:47:43 +0000200GLOBAL(void)
201jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
202 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
203 JDIMENSION output_row, int num_rows)
204{
DRC7a9376c2011-08-12 19:27:20 +0000205 void (*neonfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
206
DRC14198522014-05-15 19:45:11 +0000207 switch(cinfo->in_color_space) {
DRC7a9376c2011-08-12 19:27:20 +0000208 case JCS_EXT_RGB:
209 neonfct=jsimd_extrgb_ycc_convert_neon;
210 break;
211 case JCS_EXT_RGBX:
DRC67ce3b22011-12-19 02:21:03 +0000212 case JCS_EXT_RGBA:
DRC7a9376c2011-08-12 19:27:20 +0000213 neonfct=jsimd_extrgbx_ycc_convert_neon;
214 break;
215 case JCS_EXT_BGR:
216 neonfct=jsimd_extbgr_ycc_convert_neon;
217 break;
218 case JCS_EXT_BGRX:
DRC67ce3b22011-12-19 02:21:03 +0000219 case JCS_EXT_BGRA:
DRC7a9376c2011-08-12 19:27:20 +0000220 neonfct=jsimd_extbgrx_ycc_convert_neon;
221 break;
222 case JCS_EXT_XBGR:
DRC67ce3b22011-12-19 02:21:03 +0000223 case JCS_EXT_ABGR:
DRC7a9376c2011-08-12 19:27:20 +0000224 neonfct=jsimd_extxbgr_ycc_convert_neon;
225 break;
226 case JCS_EXT_XRGB:
DRC67ce3b22011-12-19 02:21:03 +0000227 case JCS_EXT_ARGB:
DRC7a9376c2011-08-12 19:27:20 +0000228 neonfct=jsimd_extxrgb_ycc_convert_neon;
229 break;
230 default:
231 neonfct=jsimd_extrgb_ycc_convert_neon;
232 break;
233 }
234
DRC499c4702016-01-13 03:13:20 -0600235 neonfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
DRC321e0682011-05-03 08:47:43 +0000236}
237
238GLOBAL(void)
239jsimd_rgb_gray_convert (j_compress_ptr cinfo,
240 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
241 JDIMENSION output_row, int num_rows)
242{
243}
244
245GLOBAL(void)
246jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
247 JSAMPIMAGE input_buf, JDIMENSION input_row,
248 JSAMPARRAY output_buf, int num_rows)
249{
250 void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
251
DRC14198522014-05-15 19:45:11 +0000252 switch(cinfo->out_color_space) {
DRC321e0682011-05-03 08:47:43 +0000253 case JCS_EXT_RGB:
254 neonfct=jsimd_ycc_extrgb_convert_neon;
255 break;
256 case JCS_EXT_RGBX:
DRC67ce3b22011-12-19 02:21:03 +0000257 case JCS_EXT_RGBA:
DRC321e0682011-05-03 08:47:43 +0000258 neonfct=jsimd_ycc_extrgbx_convert_neon;
259 break;
260 case JCS_EXT_BGR:
261 neonfct=jsimd_ycc_extbgr_convert_neon;
262 break;
263 case JCS_EXT_BGRX:
DRC67ce3b22011-12-19 02:21:03 +0000264 case JCS_EXT_BGRA:
DRC321e0682011-05-03 08:47:43 +0000265 neonfct=jsimd_ycc_extbgrx_convert_neon;
266 break;
267 case JCS_EXT_XBGR:
DRC67ce3b22011-12-19 02:21:03 +0000268 case JCS_EXT_ABGR:
DRC321e0682011-05-03 08:47:43 +0000269 neonfct=jsimd_ycc_extxbgr_convert_neon;
270 break;
271 case JCS_EXT_XRGB:
DRC67ce3b22011-12-19 02:21:03 +0000272 case JCS_EXT_ARGB:
DRC321e0682011-05-03 08:47:43 +0000273 neonfct=jsimd_ycc_extxrgb_convert_neon;
274 break;
DRCd729f4d2014-08-23 15:47:51 +0000275 default:
DRC321e0682011-05-03 08:47:43 +0000276 neonfct=jsimd_ycc_extrgb_convert_neon;
277 break;
278 }
279
DRC499c4702016-01-13 03:13:20 -0600280 neonfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
DRC321e0682011-05-03 08:47:43 +0000281}
282
DRCd729f4d2014-08-23 15:47:51 +0000283GLOBAL(void)
284jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
285 JSAMPIMAGE input_buf, JDIMENSION input_row,
286 JSAMPARRAY output_buf, int num_rows)
287{
DRC499c4702016-01-13 03:13:20 -0600288 jsimd_ycc_rgb565_convert_neon(cinfo->output_width, input_buf, input_row,
289 output_buf, num_rows);
DRCd729f4d2014-08-23 15:47:51 +0000290}
291
DRC321e0682011-05-03 08:47:43 +0000292GLOBAL(int)
293jsimd_can_h2v2_downsample (void)
294{
295 init_simd();
296
297 return 0;
298}
299
300GLOBAL(int)
301jsimd_can_h2v1_downsample (void)
302{
303 init_simd();
304
305 return 0;
306}
307
308GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600309jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
DRC321e0682011-05-03 08:47:43 +0000310 JSAMPARRAY input_data, JSAMPARRAY output_data)
311{
312}
313
314GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600315jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
DRC321e0682011-05-03 08:47:43 +0000316 JSAMPARRAY input_data, JSAMPARRAY output_data)
317{
318}
319
320GLOBAL(int)
321jsimd_can_h2v2_upsample (void)
322{
323 init_simd();
324
325 return 0;
326}
327
328GLOBAL(int)
329jsimd_can_h2v1_upsample (void)
330{
331 init_simd();
332
333 return 0;
334}
335
336GLOBAL(void)
337jsimd_h2v2_upsample (j_decompress_ptr cinfo,
DRCbd498032016-02-19 08:53:33 -0600338 jpeg_component_info *compptr,
DRC321e0682011-05-03 08:47:43 +0000339 JSAMPARRAY input_data,
DRCbd498032016-02-19 08:53:33 -0600340 JSAMPARRAY *output_data_ptr)
DRC321e0682011-05-03 08:47:43 +0000341{
342}
343
344GLOBAL(void)
345jsimd_h2v1_upsample (j_decompress_ptr cinfo,
DRCbd498032016-02-19 08:53:33 -0600346 jpeg_component_info *compptr,
DRC321e0682011-05-03 08:47:43 +0000347 JSAMPARRAY input_data,
DRCbd498032016-02-19 08:53:33 -0600348 JSAMPARRAY *output_data_ptr)
DRC321e0682011-05-03 08:47:43 +0000349{
350}
351
352GLOBAL(int)
353jsimd_can_h2v2_fancy_upsample (void)
354{
355 init_simd();
356
357 return 0;
358}
359
360GLOBAL(int)
361jsimd_can_h2v1_fancy_upsample (void)
362{
363 init_simd();
364
DRC316617f2012-06-13 05:17:03 +0000365 /* The code is optimised for these values only */
366 if (BITS_IN_JSAMPLE != 8)
367 return 0;
368 if (sizeof(JDIMENSION) != 4)
369 return 0;
370
371 if (simd_support & JSIMD_ARM_NEON)
372 return 1;
373
DRC321e0682011-05-03 08:47:43 +0000374 return 0;
375}
376
377GLOBAL(void)
378jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
DRCbd498032016-02-19 08:53:33 -0600379 jpeg_component_info *compptr,
DRC321e0682011-05-03 08:47:43 +0000380 JSAMPARRAY input_data,
DRCbd498032016-02-19 08:53:33 -0600381 JSAMPARRAY *output_data_ptr)
DRC321e0682011-05-03 08:47:43 +0000382{
383}
384
385GLOBAL(void)
386jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
DRCbd498032016-02-19 08:53:33 -0600387 jpeg_component_info *compptr,
DRC321e0682011-05-03 08:47:43 +0000388 JSAMPARRAY input_data,
DRCbd498032016-02-19 08:53:33 -0600389 JSAMPARRAY *output_data_ptr)
DRC321e0682011-05-03 08:47:43 +0000390{
DRC499c4702016-01-13 03:13:20 -0600391 jsimd_h2v1_fancy_upsample_neon(cinfo->max_v_samp_factor,
392 compptr->downsampled_width, input_data,
393 output_data_ptr);
DRC321e0682011-05-03 08:47:43 +0000394}
395
396GLOBAL(int)
397jsimd_can_h2v2_merged_upsample (void)
398{
399 init_simd();
400
401 return 0;
402}
403
404GLOBAL(int)
405jsimd_can_h2v1_merged_upsample (void)
406{
407 init_simd();
408
409 return 0;
410}
411
412GLOBAL(void)
413jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
414 JSAMPIMAGE input_buf,
415 JDIMENSION in_row_group_ctr,
416 JSAMPARRAY output_buf)
417{
418}
419
420GLOBAL(void)
421jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
422 JSAMPIMAGE input_buf,
423 JDIMENSION in_row_group_ctr,
424 JSAMPARRAY output_buf)
425{
426}
427
428GLOBAL(int)
429jsimd_can_convsamp (void)
430{
431 init_simd();
432
DRCb7400542011-08-10 23:31:13 +0000433 /* The code is optimised for these values only */
434 if (DCTSIZE != 8)
435 return 0;
436 if (BITS_IN_JSAMPLE != 8)
437 return 0;
438 if (sizeof(JDIMENSION) != 4)
439 return 0;
440 if (sizeof(DCTELEM) != 2)
441 return 0;
442
443 if (simd_support & JSIMD_ARM_NEON)
444 return 1;
445
DRC321e0682011-05-03 08:47:43 +0000446 return 0;
447}
448
449GLOBAL(int)
450jsimd_can_convsamp_float (void)
451{
452 init_simd();
453
454 return 0;
455}
456
457GLOBAL(void)
458jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
DRCbd498032016-02-19 08:53:33 -0600459 DCTELEM *workspace)
DRC321e0682011-05-03 08:47:43 +0000460{
DRC499c4702016-01-13 03:13:20 -0600461 jsimd_convsamp_neon(sample_data, start_col, workspace);
DRC321e0682011-05-03 08:47:43 +0000462}
463
464GLOBAL(void)
465jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
DRCbd498032016-02-19 08:53:33 -0600466 FAST_FLOAT *workspace)
DRC321e0682011-05-03 08:47:43 +0000467{
468}
469
470GLOBAL(int)
471jsimd_can_fdct_islow (void)
472{
473 init_simd();
474
475 return 0;
476}
477
478GLOBAL(int)
479jsimd_can_fdct_ifast (void)
480{
481 init_simd();
482
DRCb7400542011-08-10 23:31:13 +0000483 /* The code is optimised for these values only */
484 if (DCTSIZE != 8)
485 return 0;
486 if (sizeof(DCTELEM) != 2)
487 return 0;
488
489 if (simd_support & JSIMD_ARM_NEON)
490 return 1;
491
DRC321e0682011-05-03 08:47:43 +0000492 return 0;
493}
494
495GLOBAL(int)
496jsimd_can_fdct_float (void)
497{
498 init_simd();
499
500 return 0;
501}
502
503GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600504jsimd_fdct_islow (DCTELEM *data)
DRC321e0682011-05-03 08:47:43 +0000505{
506}
507
508GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600509jsimd_fdct_ifast (DCTELEM *data)
DRC321e0682011-05-03 08:47:43 +0000510{
DRC499c4702016-01-13 03:13:20 -0600511 jsimd_fdct_ifast_neon(data);
DRC321e0682011-05-03 08:47:43 +0000512}
513
514GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600515jsimd_fdct_float (FAST_FLOAT *data)
DRC321e0682011-05-03 08:47:43 +0000516{
517}
518
519GLOBAL(int)
520jsimd_can_quantize (void)
521{
522 init_simd();
523
DRC82bd5212011-08-17 21:00:59 +0000524 /* The code is optimised for these values only */
525 if (DCTSIZE != 8)
526 return 0;
527 if (sizeof(JCOEF) != 2)
528 return 0;
529 if (sizeof(DCTELEM) != 2)
530 return 0;
531
532 if (simd_support & JSIMD_ARM_NEON)
533 return 1;
534
DRC321e0682011-05-03 08:47:43 +0000535 return 0;
536}
537
538GLOBAL(int)
539jsimd_can_quantize_float (void)
540{
541 init_simd();
542
543 return 0;
544}
545
546GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600547jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
548 DCTELEM *workspace)
DRC321e0682011-05-03 08:47:43 +0000549{
DRC499c4702016-01-13 03:13:20 -0600550 jsimd_quantize_neon(coef_block, divisors, workspace);
DRC321e0682011-05-03 08:47:43 +0000551}
552
553GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600554jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
555 FAST_FLOAT *workspace)
DRC321e0682011-05-03 08:47:43 +0000556{
557}
558
559GLOBAL(int)
560jsimd_can_idct_2x2 (void)
561{
562 init_simd();
563
DRC8c60d222011-06-17 21:12:58 +0000564 /* 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 (BITS_IN_JSAMPLE != 8)
570 return 0;
571 if (sizeof(JDIMENSION) != 4)
572 return 0;
573 if (sizeof(ISLOW_MULT_TYPE) != 2)
574 return 0;
575
DRC14198522014-05-15 19:45:11 +0000576 if (simd_support & JSIMD_ARM_NEON)
DRC8c60d222011-06-17 21:12:58 +0000577 return 1;
578
DRC321e0682011-05-03 08:47:43 +0000579 return 0;
580}
581
582GLOBAL(int)
583jsimd_can_idct_4x4 (void)
584{
585 init_simd();
586
DRC8c60d222011-06-17 21:12:58 +0000587 /* The code is optimised for these values only */
588 if (DCTSIZE != 8)
589 return 0;
590 if (sizeof(JCOEF) != 2)
591 return 0;
592 if (BITS_IN_JSAMPLE != 8)
593 return 0;
594 if (sizeof(JDIMENSION) != 4)
595 return 0;
596 if (sizeof(ISLOW_MULT_TYPE) != 2)
597 return 0;
598
DRC14198522014-05-15 19:45:11 +0000599 if (simd_support & JSIMD_ARM_NEON)
DRC8c60d222011-06-17 21:12:58 +0000600 return 1;
601
DRC321e0682011-05-03 08:47:43 +0000602 return 0;
603}
604
605GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600606jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
DRC321e0682011-05-03 08:47:43 +0000607 JCOEFPTR coef_block, JSAMPARRAY output_buf,
608 JDIMENSION output_col)
609{
DRC499c4702016-01-13 03:13:20 -0600610 jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf,
611 output_col);
DRC321e0682011-05-03 08:47:43 +0000612}
613
614GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600615jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
DRC321e0682011-05-03 08:47:43 +0000616 JCOEFPTR coef_block, JSAMPARRAY output_buf,
617 JDIMENSION output_col)
618{
DRC499c4702016-01-13 03:13:20 -0600619 jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf,
620 output_col);
DRC321e0682011-05-03 08:47:43 +0000621}
622
623GLOBAL(int)
624jsimd_can_idct_islow (void)
625{
626 init_simd();
627
DRCce4e3e82011-08-22 13:48:01 +0000628 /* The code is optimised for these values only */
629 if (DCTSIZE != 8)
630 return 0;
631 if (sizeof(JCOEF) != 2)
632 return 0;
633 if (BITS_IN_JSAMPLE != 8)
634 return 0;
635 if (sizeof(JDIMENSION) != 4)
636 return 0;
637 if (sizeof(ISLOW_MULT_TYPE) != 2)
638 return 0;
639
640 if (simd_support & JSIMD_ARM_NEON)
641 return 1;
642
DRC321e0682011-05-03 08:47:43 +0000643 return 0;
644}
645
646GLOBAL(int)
647jsimd_can_idct_ifast (void)
648{
649 init_simd();
650
651 /* The code is optimised for these values only */
652 if (DCTSIZE != 8)
653 return 0;
654 if (sizeof(JCOEF) != 2)
655 return 0;
656 if (BITS_IN_JSAMPLE != 8)
657 return 0;
658 if (sizeof(JDIMENSION) != 4)
659 return 0;
660 if (sizeof(IFAST_MULT_TYPE) != 2)
661 return 0;
662 if (IFAST_SCALE_BITS != 2)
663 return 0;
664
DRC14198522014-05-15 19:45:11 +0000665 if (simd_support & JSIMD_ARM_NEON)
DRC321e0682011-05-03 08:47:43 +0000666 return 1;
667
668 return 0;
669}
670
671GLOBAL(int)
672jsimd_can_idct_float (void)
673{
674 init_simd();
675
676 return 0;
677}
678
679GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600680jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
DRC14198522014-05-15 19:45:11 +0000681 JCOEFPTR coef_block, JSAMPARRAY output_buf,
682 JDIMENSION output_col)
DRC321e0682011-05-03 08:47:43 +0000683{
DRC499c4702016-01-13 03:13:20 -0600684 jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf,
685 output_col);
DRC321e0682011-05-03 08:47:43 +0000686}
687
688GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600689jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
DRC14198522014-05-15 19:45:11 +0000690 JCOEFPTR coef_block, JSAMPARRAY output_buf,
691 JDIMENSION output_col)
DRC321e0682011-05-03 08:47:43 +0000692{
DRC499c4702016-01-13 03:13:20 -0600693 jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf,
694 output_col);
DRC321e0682011-05-03 08:47:43 +0000695}
696
697GLOBAL(void)
DRCbd498032016-02-19 08:53:33 -0600698jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
DRC14198522014-05-15 19:45:11 +0000699 JCOEFPTR coef_block, JSAMPARRAY output_buf,
700 JDIMENSION output_col)
DRC321e0682011-05-03 08:47:43 +0000701{
702}
DRCf3a86842016-01-07 00:19:43 -0600703
704GLOBAL(int)
705jsimd_can_huff_encode_one_block (void)
706{
DRC499c4702016-01-13 03:13:20 -0600707 init_simd();
708
709 if (DCTSIZE != 8)
710 return 0;
711 if (sizeof(JCOEF) != 2)
712 return 0;
713
DRCe8aa5fa2016-01-15 13:15:54 -0600714 if (simd_support & JSIMD_ARM_NEON && simd_huffman)
DRC499c4702016-01-13 03:13:20 -0600715 return 1;
716
DRCf3a86842016-01-07 00:19:43 -0600717 return 0;
718}
719
720GLOBAL(JOCTET*)
DRCbd498032016-02-19 08:53:33 -0600721jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
DRCf3a86842016-01-07 00:19:43 -0600722 int last_dc_val, c_derived_tbl *dctbl,
723 c_derived_tbl *actbl)
724{
DRC499c4702016-01-13 03:13:20 -0600725 return jsimd_huff_encode_one_block_neon(state, buffer, block, last_dc_val,
726 dctbl, actbl);
DRCf3a86842016-01-07 00:19:43 -0600727}