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