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