Home | History | Annotate | Download | only in simd
      1 /*
      2  * jsimd_x86_64.c
      3  *
      4  * Copyright 2009 Pierre Ossman <ossman (at) cendio.se> for Cendio AB
      5  * Copyright 2009-2011 D. R. Commander
      6  *
      7  * Based on the x86 SIMD extension for IJG JPEG library,
      8  * Copyright (C) 1999-2006, MIYASAKA Masaru.
      9  * For conditions of distribution and use, see copyright notice in jsimdext.inc
     10  *
     11  * This file contains the interface between the "normal" portions
     12  * of the library and the SIMD implementations when running on a
     13  * x86_64 architecture.
     14  */
     15 
     16 #define JPEG_INTERNALS
     17 #include "../jinclude.h"
     18 #include "../jpeglib.h"
     19 #include "../jsimd.h"
     20 #include "../jdct.h"
     21 #include "../jsimddct.h"
     22 #include "jsimd.h"
     23 
     24 /*
     25  * In the PIC cases, we have no guarantee that constants will keep
     26  * their alignment. This macro allows us to verify it at runtime.
     27  */
     28 #define IS_ALIGNED(ptr, order) (((size_t)ptr & ((1 << order) - 1)) == 0)
     29 
     30 #define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
     31 
     32 #ifndef JPEG_DECODE_ONLY
     33 GLOBAL(int)
     34 jsimd_can_rgb_ycc (void)
     35 {
     36   /* The code is optimised for these values only */
     37   if (BITS_IN_JSAMPLE != 8)
     38     return 0;
     39   if (sizeof(JDIMENSION) != 4)
     40     return 0;
     41   if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
     42     return 0;
     43 
     44   if (!IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2))
     45     return 0;
     46 
     47   return 1;
     48 }
     49 #endif
     50 
     51 GLOBAL(int)
     52 jsimd_can_rgb_gray (void)
     53 {
     54   /* The code is optimised for these values only */
     55   if (BITS_IN_JSAMPLE != 8)
     56     return 0;
     57   if (sizeof(JDIMENSION) != 4)
     58     return 0;
     59   if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
     60     return 0;
     61 
     62   if (!IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2))
     63     return 0;
     64 
     65   return 1;
     66 }
     67 
     68 GLOBAL(int)
     69 jsimd_can_ycc_rgb (void)
     70 {
     71   /* The code is optimised for these values only */
     72   if (BITS_IN_JSAMPLE != 8)
     73     return 0;
     74   if (sizeof(JDIMENSION) != 4)
     75     return 0;
     76   if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
     77     return 0;
     78 
     79   if (!IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
     80     return 0;
     81 
     82   return 1;
     83 }
     84 
     85 #ifndef JPEG_DECODE_ONLY
     86 GLOBAL(void)
     87 jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
     88                        JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
     89                        JDIMENSION output_row, int num_rows)
     90 {
     91   void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
     92 
     93   switch(cinfo->in_color_space)
     94   {
     95     case JCS_EXT_RGB:
     96       sse2fct=jsimd_extrgb_ycc_convert_sse2;
     97       break;
     98     case JCS_EXT_RGBX:
     99     case JCS_EXT_RGBA:
    100       sse2fct=jsimd_extrgbx_ycc_convert_sse2;
    101       break;
    102     case JCS_EXT_BGR:
    103       sse2fct=jsimd_extbgr_ycc_convert_sse2;
    104       break;
    105     case JCS_EXT_BGRX:
    106     case JCS_EXT_BGRA:
    107       sse2fct=jsimd_extbgrx_ycc_convert_sse2;
    108       break;
    109     case JCS_EXT_XBGR:
    110     case JCS_EXT_ABGR:
    111       sse2fct=jsimd_extxbgr_ycc_convert_sse2;
    112       break;
    113     case JCS_EXT_XRGB:
    114     case JCS_EXT_ARGB:
    115       sse2fct=jsimd_extxrgb_ycc_convert_sse2;
    116       break;
    117     default:
    118       sse2fct=jsimd_rgb_ycc_convert_sse2;
    119       break;
    120   }
    121 
    122   sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
    123 }
    124 #endif
    125 
    126 GLOBAL(void)
    127 jsimd_rgb_gray_convert (j_compress_ptr cinfo,
    128                         JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
    129                         JDIMENSION output_row, int num_rows)
    130 {
    131   void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
    132 
    133   switch(cinfo->in_color_space)
    134   {
    135     case JCS_EXT_RGB:
    136       sse2fct=jsimd_extrgb_gray_convert_sse2;
    137       break;
    138     case JCS_EXT_RGBX:
    139     case JCS_EXT_RGBA:
    140       sse2fct=jsimd_extrgbx_gray_convert_sse2;
    141       break;
    142     case JCS_EXT_BGR:
    143       sse2fct=jsimd_extbgr_gray_convert_sse2;
    144       break;
    145     case JCS_EXT_BGRX:
    146     case JCS_EXT_BGRA:
    147       sse2fct=jsimd_extbgrx_gray_convert_sse2;
    148       break;
    149     case JCS_EXT_XBGR:
    150     case JCS_EXT_ABGR:
    151       sse2fct=jsimd_extxbgr_gray_convert_sse2;
    152       break;
    153     case JCS_EXT_XRGB:
    154     case JCS_EXT_ARGB:
    155       sse2fct=jsimd_extxrgb_gray_convert_sse2;
    156       break;
    157     default:
    158       sse2fct=jsimd_rgb_gray_convert_sse2;
    159       break;
    160   }
    161 
    162   sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
    163 }
    164 
    165 GLOBAL(void)
    166 jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
    167                        JSAMPIMAGE input_buf, JDIMENSION input_row,
    168                        JSAMPARRAY output_buf, int num_rows)
    169 {
    170   void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
    171 
    172   switch(cinfo->out_color_space)
    173   {
    174     case JCS_EXT_RGB:
    175       sse2fct=jsimd_ycc_extrgb_convert_sse2;
    176       break;
    177     case JCS_EXT_RGBX:
    178     case JCS_EXT_RGBA:
    179       sse2fct=jsimd_ycc_extrgbx_convert_sse2;
    180       break;
    181     case JCS_EXT_BGR:
    182       sse2fct=jsimd_ycc_extbgr_convert_sse2;
    183       break;
    184     case JCS_EXT_BGRX:
    185     case JCS_EXT_BGRA:
    186       sse2fct=jsimd_ycc_extbgrx_convert_sse2;
    187       break;
    188     case JCS_EXT_XBGR:
    189     case JCS_EXT_ABGR:
    190       sse2fct=jsimd_ycc_extxbgr_convert_sse2;
    191       break;
    192     case JCS_EXT_XRGB:
    193     case JCS_EXT_ARGB:
    194       sse2fct=jsimd_ycc_extxrgb_convert_sse2;
    195       break;
    196     default:
    197       sse2fct=jsimd_ycc_rgb_convert_sse2;
    198       break;
    199   }
    200 
    201   sse2fct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
    202 }
    203 
    204 #ifndef JPEG_DECODE_ONLY
    205 GLOBAL(int)
    206 jsimd_can_h2v2_downsample (void)
    207 {
    208   /* The code is optimised for these values only */
    209   if (BITS_IN_JSAMPLE != 8)
    210     return 0;
    211   if (sizeof(JDIMENSION) != 4)
    212     return 0;
    213 
    214   return 1;
    215 }
    216 
    217 GLOBAL(int)
    218 jsimd_can_h2v1_downsample (void)
    219 {
    220   /* The code is optimised for these values only */
    221   if (BITS_IN_JSAMPLE != 8)
    222     return 0;
    223   if (sizeof(JDIMENSION) != 4)
    224     return 0;
    225 
    226   return 1;
    227 }
    228 
    229 GLOBAL(void)
    230 jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
    231                        JSAMPARRAY input_data, JSAMPARRAY output_data)
    232 {
    233   jsimd_h2v2_downsample_sse2(cinfo->image_width,
    234                              cinfo->max_v_samp_factor,
    235                              compptr->v_samp_factor,
    236                              compptr->width_in_blocks,
    237                              input_data, output_data);
    238 }
    239 
    240 GLOBAL(void)
    241 jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
    242                        JSAMPARRAY input_data, JSAMPARRAY output_data)
    243 {
    244   jsimd_h2v1_downsample_sse2(cinfo->image_width,
    245                              cinfo->max_v_samp_factor,
    246                              compptr->v_samp_factor,
    247                              compptr->width_in_blocks,
    248                              input_data, output_data);
    249 }
    250 #endif
    251 
    252 GLOBAL(int)
    253 jsimd_can_h2v2_upsample (void)
    254 {
    255   /* The code is optimised for these values only */
    256   if (BITS_IN_JSAMPLE != 8)
    257     return 0;
    258   if (sizeof(JDIMENSION) != 4)
    259     return 0;
    260 
    261   return 1;
    262 }
    263 
    264 GLOBAL(int)
    265 jsimd_can_h2v1_upsample (void)
    266 {
    267   /* The code is optimised for these values only */
    268   if (BITS_IN_JSAMPLE != 8)
    269     return 0;
    270   if (sizeof(JDIMENSION) != 4)
    271     return 0;
    272 
    273   return 1;
    274 }
    275 
    276 GLOBAL(void)
    277 jsimd_h2v2_upsample (j_decompress_ptr cinfo,
    278                      jpeg_component_info * compptr,
    279                      JSAMPARRAY input_data,
    280                      JSAMPARRAY * output_data_ptr)
    281 {
    282   jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor,
    283                            cinfo->output_width,
    284                            input_data, output_data_ptr);
    285 }
    286 
    287 GLOBAL(void)
    288 jsimd_h2v1_upsample (j_decompress_ptr cinfo,
    289                      jpeg_component_info * compptr,
    290                      JSAMPARRAY input_data,
    291                      JSAMPARRAY * output_data_ptr)
    292 {
    293   jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor,
    294                            cinfo->output_width,
    295                            input_data, output_data_ptr);
    296 }
    297 
    298 GLOBAL(int)
    299 jsimd_can_h2v2_fancy_upsample (void)
    300 {
    301   /* The code is optimised for these values only */
    302   if (BITS_IN_JSAMPLE != 8)
    303     return 0;
    304   if (sizeof(JDIMENSION) != 4)
    305     return 0;
    306 
    307   if (!IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
    308     return 0;
    309 
    310   return 1;
    311 }
    312 
    313 GLOBAL(int)
    314 jsimd_can_h2v1_fancy_upsample (void)
    315 {
    316   /* The code is optimised for these values only */
    317   if (BITS_IN_JSAMPLE != 8)
    318     return 0;
    319   if (sizeof(JDIMENSION) != 4)
    320     return 0;
    321 
    322   if (!IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
    323     return 0;
    324 
    325   return 1;
    326 }
    327 
    328 GLOBAL(void)
    329 jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
    330                            jpeg_component_info * compptr,
    331                            JSAMPARRAY input_data,
    332                            JSAMPARRAY * output_data_ptr)
    333 {
    334   jsimd_h2v2_fancy_upsample_sse2(cinfo->max_v_samp_factor,
    335                                  compptr->downsampled_width,
    336                                  input_data, output_data_ptr);
    337 }
    338 
    339 GLOBAL(void)
    340 jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
    341                            jpeg_component_info * compptr,
    342                            JSAMPARRAY input_data,
    343                            JSAMPARRAY * output_data_ptr)
    344 {
    345   jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor,
    346                                  compptr->downsampled_width,
    347                                  input_data, output_data_ptr);
    348 }
    349 
    350 GLOBAL(int)
    351 jsimd_can_h2v2_merged_upsample (void)
    352 {
    353   /* The code is optimised for these values only */
    354   if (BITS_IN_JSAMPLE != 8)
    355     return 0;
    356   if (sizeof(JDIMENSION) != 4)
    357     return 0;
    358 
    359   if (!IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
    360     return 0;
    361 
    362   return 1;
    363 }
    364 
    365 GLOBAL(int)
    366 jsimd_can_h2v1_merged_upsample (void)
    367 {
    368   /* The code is optimised for these values only */
    369   if (BITS_IN_JSAMPLE != 8)
    370     return 0;
    371   if (sizeof(JDIMENSION) != 4)
    372     return 0;
    373 
    374   if (!IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
    375     return 0;
    376 
    377   return 1;
    378 }
    379 
    380 GLOBAL(void)
    381 jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
    382                             JSAMPIMAGE input_buf,
    383                             JDIMENSION in_row_group_ctr,
    384                             JSAMPARRAY output_buf)
    385 {
    386   void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
    387 
    388   switch(cinfo->out_color_space)
    389   {
    390     case JCS_EXT_RGB:
    391       sse2fct=jsimd_h2v2_extrgb_merged_upsample_sse2;
    392       break;
    393     case JCS_EXT_RGBX:
    394     case JCS_EXT_RGBA:
    395       sse2fct=jsimd_h2v2_extrgbx_merged_upsample_sse2;
    396       break;
    397     case JCS_EXT_BGR:
    398       sse2fct=jsimd_h2v2_extbgr_merged_upsample_sse2;
    399       break;
    400     case JCS_EXT_BGRX:
    401     case JCS_EXT_BGRA:
    402       sse2fct=jsimd_h2v2_extbgrx_merged_upsample_sse2;
    403       break;
    404     case JCS_EXT_XBGR:
    405     case JCS_EXT_ABGR:
    406       sse2fct=jsimd_h2v2_extxbgr_merged_upsample_sse2;
    407       break;
    408     case JCS_EXT_XRGB:
    409     case JCS_EXT_ARGB:
    410       sse2fct=jsimd_h2v2_extxrgb_merged_upsample_sse2;
    411       break;
    412     default:
    413       sse2fct=jsimd_h2v2_merged_upsample_sse2;
    414       break;
    415   }
    416 
    417   sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
    418 }
    419 
    420 GLOBAL(void)
    421 jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
    422                             JSAMPIMAGE input_buf,
    423                             JDIMENSION in_row_group_ctr,
    424                             JSAMPARRAY output_buf)
    425 {
    426   void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
    427 
    428   switch(cinfo->out_color_space)
    429   {
    430     case JCS_EXT_RGB:
    431       sse2fct=jsimd_h2v1_extrgb_merged_upsample_sse2;
    432       break;
    433     case JCS_EXT_RGBX:
    434     case JCS_EXT_RGBA:
    435       sse2fct=jsimd_h2v1_extrgbx_merged_upsample_sse2;
    436       break;
    437     case JCS_EXT_BGR:
    438       sse2fct=jsimd_h2v1_extbgr_merged_upsample_sse2;
    439       break;
    440     case JCS_EXT_BGRX:
    441     case JCS_EXT_BGRA:
    442       sse2fct=jsimd_h2v1_extbgrx_merged_upsample_sse2;
    443       break;
    444     case JCS_EXT_XBGR:
    445     case JCS_EXT_ABGR:
    446       sse2fct=jsimd_h2v1_extxbgr_merged_upsample_sse2;
    447       break;
    448     case JCS_EXT_XRGB:
    449     case JCS_EXT_ARGB:
    450       sse2fct=jsimd_h2v1_extxrgb_merged_upsample_sse2;
    451       break;
    452     default:
    453       sse2fct=jsimd_h2v1_merged_upsample_sse2;
    454       break;
    455   }
    456 
    457   sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
    458 }
    459 
    460 #ifndef JPEG_DECODE_ONLY
    461 GLOBAL(int)
    462 jsimd_can_convsamp (void)
    463 {
    464   /* The code is optimised for these values only */
    465   if (DCTSIZE != 8)
    466     return 0;
    467   if (BITS_IN_JSAMPLE != 8)
    468     return 0;
    469   if (sizeof(JDIMENSION) != 4)
    470     return 0;
    471   if (sizeof(DCTELEM) != 2)
    472     return 0;
    473 
    474   return 1;
    475 }
    476 
    477 GLOBAL(int)
    478 jsimd_can_convsamp_float (void)
    479 {
    480   /* The code is optimised for these values only */
    481   if (DCTSIZE != 8)
    482     return 0;
    483   if (BITS_IN_JSAMPLE != 8)
    484     return 0;
    485   if (sizeof(JDIMENSION) != 4)
    486     return 0;
    487   if (sizeof(FAST_FLOAT) != 4)
    488     return 0;
    489 
    490   return 1;
    491 }
    492 
    493 GLOBAL(void)
    494 jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
    495                 DCTELEM * workspace)
    496 {
    497   jsimd_convsamp_sse2(sample_data, start_col, workspace);
    498 }
    499 
    500 GLOBAL(void)
    501 jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
    502                       FAST_FLOAT * workspace)
    503 {
    504   jsimd_convsamp_float_sse2(sample_data, start_col, workspace);
    505 }
    506 
    507 GLOBAL(int)
    508 jsimd_can_fdct_islow (void)
    509 {
    510   /* The code is optimised for these values only */
    511   if (DCTSIZE != 8)
    512     return 0;
    513   if (sizeof(DCTELEM) != 2)
    514     return 0;
    515 
    516   if (!IS_ALIGNED_SSE(jconst_fdct_islow_sse2))
    517     return 0;
    518 
    519   return 1;
    520 }
    521 
    522 GLOBAL(int)
    523 jsimd_can_fdct_ifast (void)
    524 {
    525   /* The code is optimised for these values only */
    526   if (DCTSIZE != 8)
    527     return 0;
    528   if (sizeof(DCTELEM) != 2)
    529     return 0;
    530 
    531   if (!IS_ALIGNED_SSE(jconst_fdct_ifast_sse2))
    532     return 0;
    533 
    534   return 1;
    535 }
    536 
    537 GLOBAL(int)
    538 jsimd_can_fdct_float (void)
    539 {
    540   /* The code is optimised for these values only */
    541   if (DCTSIZE != 8)
    542     return 0;
    543   if (sizeof(FAST_FLOAT) != 4)
    544     return 0;
    545 
    546   if (!IS_ALIGNED_SSE(jconst_fdct_float_sse))
    547     return 0;
    548 
    549   return 1;
    550 }
    551 
    552 GLOBAL(void)
    553 jsimd_fdct_islow (DCTELEM * data)
    554 {
    555   jsimd_fdct_islow_sse2(data);
    556 }
    557 
    558 GLOBAL(void)
    559 jsimd_fdct_ifast (DCTELEM * data)
    560 {
    561   jsimd_fdct_ifast_sse2(data);
    562 }
    563 
    564 GLOBAL(void)
    565 jsimd_fdct_float (FAST_FLOAT * data)
    566 {
    567   jsimd_fdct_float_sse(data);
    568 }
    569 
    570 GLOBAL(int)
    571 jsimd_can_quantize (void)
    572 {
    573   /* The code is optimised for these values only */
    574   if (DCTSIZE != 8)
    575     return 0;
    576   if (sizeof(JCOEF) != 2)
    577     return 0;
    578   if (sizeof(DCTELEM) != 2)
    579     return 0;
    580 
    581   return 1;
    582 }
    583 
    584 GLOBAL(int)
    585 jsimd_can_quantize_float (void)
    586 {
    587   /* 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 (sizeof(FAST_FLOAT) != 4)
    593     return 0;
    594 
    595   return 1;
    596 }
    597 
    598 GLOBAL(void)
    599 jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors,
    600                 DCTELEM * workspace)
    601 {
    602   jsimd_quantize_sse2(coef_block, divisors, workspace);
    603 }
    604 
    605 GLOBAL(void)
    606 jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors,
    607                       FAST_FLOAT * workspace)
    608 {
    609   jsimd_quantize_float_sse2(coef_block, divisors, workspace);
    610 }
    611 #endif
    612 
    613 GLOBAL(int)
    614 jsimd_can_idct_2x2 (void)
    615 {
    616   /* The code is optimised for these values only */
    617   if (DCTSIZE != 8)
    618     return 0;
    619   if (sizeof(JCOEF) != 2)
    620     return 0;
    621   if (BITS_IN_JSAMPLE != 8)
    622     return 0;
    623   if (sizeof(JDIMENSION) != 4)
    624     return 0;
    625   if (sizeof(ISLOW_MULT_TYPE) != 2)
    626     return 0;
    627 
    628   if (!IS_ALIGNED_SSE(jconst_idct_red_sse2))
    629     return 0;
    630 
    631   return 1;
    632 }
    633 
    634 GLOBAL(int)
    635 jsimd_can_idct_4x4 (void)
    636 {
    637   /* The code is optimised for these values only */
    638   if (DCTSIZE != 8)
    639     return 0;
    640   if (sizeof(JCOEF) != 2)
    641     return 0;
    642   if (BITS_IN_JSAMPLE != 8)
    643     return 0;
    644   if (sizeof(JDIMENSION) != 4)
    645     return 0;
    646   if (sizeof(ISLOW_MULT_TYPE) != 2)
    647     return 0;
    648 
    649   if (!IS_ALIGNED_SSE(jconst_idct_red_sse2))
    650     return 0;
    651 
    652   return 1;
    653 }
    654 
    655 GLOBAL(void)
    656 jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
    657                 JCOEFPTR coef_block, JSAMPARRAY output_buf,
    658                 JDIMENSION output_col)
    659 {
    660   jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf, output_col);
    661 }
    662 
    663 GLOBAL(void)
    664 jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
    665                 JCOEFPTR coef_block, JSAMPARRAY output_buf,
    666                 JDIMENSION output_col)
    667 {
    668   jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf, output_col);
    669 }
    670 
    671 GLOBAL(int)
    672 jsimd_can_idct_islow (void)
    673 {
    674   /* The code is optimised for these values only */
    675   if (DCTSIZE != 8)
    676     return 0;
    677   if (sizeof(JCOEF) != 2)
    678     return 0;
    679   if (BITS_IN_JSAMPLE != 8)
    680     return 0;
    681   if (sizeof(JDIMENSION) != 4)
    682     return 0;
    683   if (sizeof(ISLOW_MULT_TYPE) != 2)
    684     return 0;
    685 
    686   if (!IS_ALIGNED_SSE(jconst_idct_islow_sse2))
    687     return 0;
    688 
    689   return 1;
    690 }
    691 
    692 GLOBAL(int)
    693 jsimd_can_idct_ifast (void)
    694 {
    695   /* The code is optimised for these values only */
    696   if (DCTSIZE != 8)
    697     return 0;
    698   if (sizeof(JCOEF) != 2)
    699     return 0;
    700   if (BITS_IN_JSAMPLE != 8)
    701     return 0;
    702   if (sizeof(JDIMENSION) != 4)
    703     return 0;
    704   if (sizeof(IFAST_MULT_TYPE) != 2)
    705     return 0;
    706   if (IFAST_SCALE_BITS != 2)
    707     return 0;
    708 
    709   if (!IS_ALIGNED_SSE(jconst_idct_ifast_sse2))
    710     return 0;
    711 
    712   return 1;
    713 }
    714 
    715 GLOBAL(int)
    716 jsimd_can_idct_float (void)
    717 {
    718   if (DCTSIZE != 8)
    719     return 0;
    720   if (sizeof(JCOEF) != 2)
    721     return 0;
    722   if (BITS_IN_JSAMPLE != 8)
    723     return 0;
    724   if (sizeof(JDIMENSION) != 4)
    725     return 0;
    726   if (sizeof(FAST_FLOAT) != 4)
    727     return 0;
    728   if (sizeof(FLOAT_MULT_TYPE) != 4)
    729     return 0;
    730 
    731   if (!IS_ALIGNED_SSE(jconst_idct_float_sse2))
    732     return 0;
    733 
    734   return 1;
    735 }
    736 
    737 GLOBAL(void)
    738 jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
    739                 JCOEFPTR coef_block, JSAMPARRAY output_buf,
    740                 JDIMENSION output_col)
    741 {
    742   jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf, output_col);
    743 }
    744 
    745 GLOBAL(void)
    746 jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
    747                 JCOEFPTR coef_block, JSAMPARRAY output_buf,
    748                 JDIMENSION output_col)
    749 {
    750   jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf, output_col);
    751 }
    752 
    753 GLOBAL(void)
    754 jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
    755                 JCOEFPTR coef_block, JSAMPARRAY output_buf,
    756                 JDIMENSION output_col)
    757 {
    758   jsimd_idct_float_sse2(compptr->dct_table, coef_block,
    759                         output_buf, output_col);
    760 }
    761