| Index: simd/jsimd_x86_64.c
|
| diff --git a/simd/jsimd_x86_64.c b/simd/jsimd_x86_64.c
|
| index d6008617c543672069aec4ef14398e4dd4b5b192..fa33bea0dc8d71dc54d48f0ee6c1a8edfd0cd226 100644
|
| --- a/simd/jsimd_x86_64.c
|
| +++ b/simd/jsimd_x86_64.c
|
| @@ -2,15 +2,16 @@
|
| * jsimd_x86_64.c
|
| *
|
| * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
| - * Copyright 2009-2011, 2014 D. R. Commander
|
| - *
|
| + * Copyright 2009-2011, 2014, 2016 D. R. Commander
|
| + * Copyright 2015 Matthieu Darbois
|
| + *
|
| * Based on the x86 SIMD extension for IJG JPEG library,
|
| * Copyright (C) 1999-2006, MIYASAKA Masaru.
|
| * For conditions of distribution and use, see copyright notice in jsimdext.inc
|
| *
|
| * This file contains the interface between the "normal" portions
|
| * of the library and the SIMD implementations when running on a
|
| - * x86_64 architecture.
|
| + * 64-bit x86 architecture.
|
| */
|
|
|
| #define JPEG_INTERNALS
|
| @@ -29,10 +30,38 @@
|
|
|
| #define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
|
|
|
| -#ifndef JPEG_DECODE_ONLY
|
| +static unsigned int simd_support = ~0;
|
| +static unsigned int simd_huffman = 1;
|
| +
|
| +/*
|
| + * Check what SIMD accelerations are supported.
|
| + *
|
| + * FIXME: This code is racy under a multi-threaded environment.
|
| + */
|
| +LOCAL(void)
|
| +init_simd (void)
|
| +{
|
| + char *env = NULL;
|
| +
|
| + if (simd_support != ~0U)
|
| + return;
|
| +
|
| + simd_support = JSIMD_SSE2 | JSIMD_SSE;
|
| +
|
| + /* Force different settings through environment variables */
|
| + env = getenv("JSIMD_FORCENONE");
|
| + if ((env != NULL) && (strcmp(env, "1") == 0))
|
| + simd_support = 0;
|
| + env = getenv("JSIMD_NOHUFFENC");
|
| + if ((env != NULL) && (strcmp(env, "1") == 0))
|
| + simd_huffman = 0;
|
| +}
|
| +
|
| GLOBAL(int)
|
| jsimd_can_rgb_ycc (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| @@ -41,16 +70,18 @@ jsimd_can_rgb_ycc (void)
|
| if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) &&
|
| + IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
| -#endif
|
|
|
| GLOBAL(int)
|
| jsimd_can_rgb_gray (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| @@ -59,15 +90,18 @@ jsimd_can_rgb_gray (void)
|
| if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) &&
|
| + IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_ycc_rgb (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| @@ -76,10 +110,11 @@ jsimd_can_ycc_rgb (void)
|
| if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) &&
|
| + IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| @@ -88,7 +123,6 @@ jsimd_can_ycc_rgb565 (void)
|
| return 0;
|
| }
|
|
|
| -#ifndef JPEG_DECODE_ONLY
|
| GLOBAL(void)
|
| jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
|
| JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
| @@ -96,8 +130,7 @@ jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
|
| {
|
| void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
|
|
|
| - switch(cinfo->in_color_space)
|
| - {
|
| + switch(cinfo->in_color_space) {
|
| case JCS_EXT_RGB:
|
| sse2fct=jsimd_extrgb_ycc_convert_sse2;
|
| break;
|
| @@ -127,7 +160,6 @@ jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
|
|
|
| sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
|
| }
|
| -#endif
|
|
|
| GLOBAL(void)
|
| jsimd_rgb_gray_convert (j_compress_ptr cinfo,
|
| @@ -136,8 +168,7 @@ jsimd_rgb_gray_convert (j_compress_ptr cinfo,
|
| {
|
| void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
|
|
|
| - switch(cinfo->in_color_space)
|
| - {
|
| + switch(cinfo->in_color_space) {
|
| case JCS_EXT_RGB:
|
| sse2fct=jsimd_extrgb_gray_convert_sse2;
|
| break;
|
| @@ -175,8 +206,7 @@ jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
|
| {
|
| void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
|
|
|
| - switch(cinfo->out_color_space)
|
| - {
|
| + switch(cinfo->out_color_space) {
|
| case JCS_EXT_RGB:
|
| sse2fct=jsimd_ycc_extrgb_convert_sse2;
|
| break;
|
| @@ -214,180 +244,204 @@ jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
|
| {
|
| }
|
|
|
| -#ifndef JPEG_DECODE_ONLY
|
| GLOBAL(int)
|
| jsimd_can_h2v2_downsample (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| if (sizeof(JDIMENSION) != 4)
|
| return 0;
|
|
|
| - return 1;
|
| + if (simd_support & JSIMD_SSE2)
|
| + return 1;
|
| +
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_h2v1_downsample (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| if (sizeof(JDIMENSION) != 4)
|
| return 0;
|
|
|
| - return 1;
|
| + if (simd_support & JSIMD_SSE2)
|
| + return 1;
|
| +
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
| +jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
| JSAMPARRAY input_data, JSAMPARRAY output_data)
|
| {
|
| - jsimd_h2v2_downsample_sse2(cinfo->image_width,
|
| - cinfo->max_v_samp_factor,
|
| - compptr->v_samp_factor,
|
| - compptr->width_in_blocks,
|
| + jsimd_h2v2_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor,
|
| + compptr->v_samp_factor, compptr->width_in_blocks,
|
| input_data, output_data);
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
| +jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
| JSAMPARRAY input_data, JSAMPARRAY output_data)
|
| {
|
| - jsimd_h2v1_downsample_sse2(cinfo->image_width,
|
| - cinfo->max_v_samp_factor,
|
| - compptr->v_samp_factor,
|
| - compptr->width_in_blocks,
|
| + jsimd_h2v1_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor,
|
| + compptr->v_samp_factor, compptr->width_in_blocks,
|
| input_data, output_data);
|
| }
|
| -#endif
|
|
|
| GLOBAL(int)
|
| jsimd_can_h2v2_upsample (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| if (sizeof(JDIMENSION) != 4)
|
| return 0;
|
|
|
| - return 1;
|
| + if (simd_support & JSIMD_SSE2)
|
| + return 1;
|
| +
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_h2v1_upsample (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| if (sizeof(JDIMENSION) != 4)
|
| return 0;
|
|
|
| - return 1;
|
| + if (simd_support & JSIMD_SSE2)
|
| + return 1;
|
| +
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| jsimd_h2v2_upsample (j_decompress_ptr cinfo,
|
| - jpeg_component_info * compptr,
|
| + jpeg_component_info *compptr,
|
| JSAMPARRAY input_data,
|
| - JSAMPARRAY * output_data_ptr)
|
| + JSAMPARRAY *output_data_ptr)
|
| {
|
| - jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor,
|
| - cinfo->output_width,
|
| + jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width,
|
| input_data, output_data_ptr);
|
| }
|
|
|
| GLOBAL(void)
|
| jsimd_h2v1_upsample (j_decompress_ptr cinfo,
|
| - jpeg_component_info * compptr,
|
| + jpeg_component_info *compptr,
|
| JSAMPARRAY input_data,
|
| - JSAMPARRAY * output_data_ptr)
|
| + JSAMPARRAY *output_data_ptr)
|
| {
|
| - jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor,
|
| - cinfo->output_width,
|
| + jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width,
|
| input_data, output_data_ptr);
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_h2v2_fancy_upsample (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| if (sizeof(JDIMENSION) != 4)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) &&
|
| + IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_h2v1_fancy_upsample (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| if (sizeof(JDIMENSION) != 4)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) &&
|
| + IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
|
| - jpeg_component_info * compptr,
|
| + jpeg_component_info *compptr,
|
| JSAMPARRAY input_data,
|
| - JSAMPARRAY * output_data_ptr)
|
| + JSAMPARRAY *output_data_ptr)
|
| {
|
| jsimd_h2v2_fancy_upsample_sse2(cinfo->max_v_samp_factor,
|
| - compptr->downsampled_width,
|
| - input_data, output_data_ptr);
|
| + compptr->downsampled_width, input_data,
|
| + output_data_ptr);
|
| }
|
|
|
| GLOBAL(void)
|
| jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
|
| - jpeg_component_info * compptr,
|
| + jpeg_component_info *compptr,
|
| JSAMPARRAY input_data,
|
| - JSAMPARRAY * output_data_ptr)
|
| + JSAMPARRAY *output_data_ptr)
|
| {
|
| jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor,
|
| - compptr->downsampled_width,
|
| - input_data, output_data_ptr);
|
| + compptr->downsampled_width, input_data,
|
| + output_data_ptr);
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_h2v2_merged_upsample (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| if (sizeof(JDIMENSION) != 4)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) &&
|
| + IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_h2v1_merged_upsample (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (BITS_IN_JSAMPLE != 8)
|
| return 0;
|
| if (sizeof(JDIMENSION) != 4)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) &&
|
| + IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| @@ -398,8 +452,7 @@ jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
|
| {
|
| void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
|
|
|
| - switch(cinfo->out_color_space)
|
| - {
|
| + switch(cinfo->out_color_space) {
|
| case JCS_EXT_RGB:
|
| sse2fct=jsimd_h2v2_extrgb_merged_upsample_sse2;
|
| break;
|
| @@ -438,8 +491,7 @@ jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
|
| {
|
| void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
|
|
|
| - switch(cinfo->out_color_space)
|
| - {
|
| + switch(cinfo->out_color_space) {
|
| case JCS_EXT_RGB:
|
| sse2fct=jsimd_h2v1_extrgb_merged_upsample_sse2;
|
| break;
|
| @@ -470,10 +522,11 @@ jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
|
| sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
|
| }
|
|
|
| -#ifndef JPEG_DECODE_ONLY
|
| GLOBAL(int)
|
| jsimd_can_convsamp (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| @@ -484,12 +537,17 @@ jsimd_can_convsamp (void)
|
| if (sizeof(DCTELEM) != 2)
|
| return 0;
|
|
|
| - return 1;
|
| + if (simd_support & JSIMD_SSE2)
|
| + return 1;
|
| +
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_convsamp_float (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| @@ -500,19 +558,22 @@ jsimd_can_convsamp_float (void)
|
| if (sizeof(FAST_FLOAT) != 4)
|
| return 0;
|
|
|
| - return 1;
|
| + if (simd_support & JSIMD_SSE2)
|
| + return 1;
|
| +
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
|
| - DCTELEM * workspace)
|
| + DCTELEM *workspace)
|
| {
|
| jsimd_convsamp_sse2(sample_data, start_col, workspace);
|
| }
|
|
|
| GLOBAL(void)
|
| jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
|
| - FAST_FLOAT * workspace)
|
| + FAST_FLOAT *workspace)
|
| {
|
| jsimd_convsamp_float_sse2(sample_data, start_col, workspace);
|
| }
|
| @@ -520,62 +581,68 @@ jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
|
| GLOBAL(int)
|
| jsimd_can_fdct_islow (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| if (sizeof(DCTELEM) != 2)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_fdct_islow_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_fdct_ifast (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| if (sizeof(DCTELEM) != 2)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_fdct_ifast_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_ifast_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_fdct_float (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| if (sizeof(FAST_FLOAT) != 4)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_fdct_float_sse))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_fdct_islow (DCTELEM * data)
|
| +jsimd_fdct_islow (DCTELEM *data)
|
| {
|
| jsimd_fdct_islow_sse2(data);
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_fdct_ifast (DCTELEM * data)
|
| +jsimd_fdct_ifast (DCTELEM *data)
|
| {
|
| jsimd_fdct_ifast_sse2(data);
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_fdct_float (FAST_FLOAT * data)
|
| +jsimd_fdct_float (FAST_FLOAT *data)
|
| {
|
| jsimd_fdct_float_sse(data);
|
| }
|
| @@ -583,6 +650,8 @@ jsimd_fdct_float (FAST_FLOAT * data)
|
| GLOBAL(int)
|
| jsimd_can_quantize (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| @@ -591,12 +660,17 @@ jsimd_can_quantize (void)
|
| if (sizeof(DCTELEM) != 2)
|
| return 0;
|
|
|
| - return 1;
|
| + if (simd_support & JSIMD_SSE2)
|
| + return 1;
|
| +
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_quantize_float (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| @@ -605,27 +679,31 @@ jsimd_can_quantize_float (void)
|
| if (sizeof(FAST_FLOAT) != 4)
|
| return 0;
|
|
|
| - return 1;
|
| + if (simd_support & JSIMD_SSE2)
|
| + return 1;
|
| +
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors,
|
| - DCTELEM * workspace)
|
| +jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
|
| + DCTELEM *workspace)
|
| {
|
| jsimd_quantize_sse2(coef_block, divisors, workspace);
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors,
|
| - FAST_FLOAT * workspace)
|
| +jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
|
| + FAST_FLOAT *workspace)
|
| {
|
| jsimd_quantize_float_sse2(coef_block, divisors, workspace);
|
| }
|
| -#endif
|
|
|
| GLOBAL(int)
|
| jsimd_can_idct_2x2 (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| @@ -638,15 +716,17 @@ jsimd_can_idct_2x2 (void)
|
| if (sizeof(ISLOW_MULT_TYPE) != 2)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_idct_red_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_idct_4x4 (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| @@ -659,14 +739,14 @@ jsimd_can_idct_4x4 (void)
|
| if (sizeof(ISLOW_MULT_TYPE) != 2)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_idct_red_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| +jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
| JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
| JDIMENSION output_col)
|
| {
|
| @@ -674,7 +754,7 @@ jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| +jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
| JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
| JDIMENSION output_col)
|
| {
|
| @@ -684,6 +764,8 @@ jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| GLOBAL(int)
|
| jsimd_can_idct_islow (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| @@ -696,15 +778,17 @@ jsimd_can_idct_islow (void)
|
| if (sizeof(ISLOW_MULT_TYPE) != 2)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_idct_islow_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_idct_ifast (void)
|
| {
|
| + init_simd();
|
| +
|
| /* The code is optimised for these values only */
|
| if (DCTSIZE != 8)
|
| return 0;
|
| @@ -719,15 +803,17 @@ jsimd_can_idct_ifast (void)
|
| if (IFAST_SCALE_BITS != 2)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_idct_ifast_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(int)
|
| jsimd_can_idct_float (void)
|
| {
|
| + init_simd();
|
| +
|
| if (DCTSIZE != 8)
|
| return 0;
|
| if (sizeof(JCOEF) != 2)
|
| @@ -741,33 +827,61 @@ jsimd_can_idct_float (void)
|
| if (sizeof(FLOAT_MULT_TYPE) != 4)
|
| return 0;
|
|
|
| - if (!IS_ALIGNED_SSE(jconst_idct_float_sse2))
|
| - return 0;
|
| + if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2))
|
| + return 1;
|
|
|
| - return 1;
|
| + return 0;
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| - JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
| - JDIMENSION output_col)
|
| +jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
| + JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
| + JDIMENSION output_col)
|
| {
|
| - jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf, output_col);
|
| + jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf,
|
| + output_col);
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| - JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
| - JDIMENSION output_col)
|
| +jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
| + JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
| + JDIMENSION output_col)
|
| {
|
| - jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf, output_col);
|
| + jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf,
|
| + output_col);
|
| }
|
|
|
| GLOBAL(void)
|
| -jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
| - JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
| - JDIMENSION output_col)
|
| +jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
| + JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
| + JDIMENSION output_col)
|
| +{
|
| + jsimd_idct_float_sse2(compptr->dct_table, coef_block, output_buf,
|
| + output_col);
|
| +}
|
| +
|
| +GLOBAL(int)
|
| +jsimd_can_huff_encode_one_block (void)
|
| +{
|
| + init_simd();
|
| +
|
| + if (DCTSIZE != 8)
|
| + return 0;
|
| + if (sizeof(JCOEF) != 2)
|
| + return 0;
|
| +
|
| + if ((simd_support & JSIMD_SSE2) && simd_huffman &&
|
| + IS_ALIGNED_SSE(jconst_huff_encode_one_block))
|
| + return 1;
|
| +
|
| + return 0;
|
| +}
|
| +
|
| +GLOBAL(JOCTET*)
|
| +jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
|
| + int last_dc_val, c_derived_tbl *dctbl,
|
| + c_derived_tbl *actbl)
|
| {
|
| - jsimd_idct_float_sse2(compptr->dct_table, coef_block,
|
| - output_buf, output_col);
|
| + return jsimd_huff_encode_one_block_sse2(state, buffer, block, last_dc_val,
|
| + dctbl, actbl);
|
| }
|
|
|