| diff --git a/configure.ac b/configure.ac |
| --- a/configure.ac 2016-08-29 11:46:27.000000000 -0400 |
| +++ b/configure.ac 2016-08-29 16:57:03.866355018 -0400 |
| @@ -386,16 +386,51 @@ AC_ARG_ENABLE([mips-msa], |
| # future host CPU does not match 'mips*') |
| |
| AM_CONDITIONAL([PNG_MIPS_MSA], |
| [test "$enable_mips_msa" != 'no' && |
| case "$host_cpu" in |
| mipsel*|mips64el*) :;; |
| esac]) |
| |
| +# INTEL |
| +# ===== |
| +# |
| +# INTEL SSE (SIMD) support. |
| + |
| +AC_ARG_ENABLE([intel-sse], |
| + AS_HELP_STRING([[[--enable-intel-sse]]], |
| + [Enable Intel SSE optimizations: =no/off, yes/on:] |
| + [no/off: disable the optimizations;] |
| + [yes/on: enable the optimizations.] |
| + [If not specified: determined by the compiler.]), |
| + [case "$enableval" in |
| + no|off) |
| + # disable the default enabling: |
| + AC_DEFINE([PNG_INTEL_SSE_OPT], [0], |
| + [Disable Intel SSE optimizations]) |
| + # Prevent inclusion of the assembler files below: |
| + enable_intel_sse=no;; |
| + yes|on) |
| + AC_DEFINE([PNG_INTEL_SSE_OPT], [1], |
| + [Enable Intel SSE optimizations]);; |
| + *) |
| + AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value]) |
| + esac]) |
| + |
| +# Add Intel specific files to all builds where the host_cpu is Intel ('x86*') |
| +# or where Intel optimizations were explicitly requested (this allows a |
| +# fallback if a future host CPU does not match 'x86*') |
| +AM_CONDITIONAL([PNG_INTEL_SSE], |
| + [test "$enable_intel_sse" != 'no' && |
| + case "$host_cpu" in |
| + i?86|x86_64) :;; |
| + *) test "$enable_intel_sse" != '';; |
| + esac]) |
| + |
| AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) |
| |
| # Config files, substituting as above |
| AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in]) |
| AC_CONFIG_FILES([libpng-config:libpng-config.in], |
| [chmod +x libpng-config]) |
| |
| AC_OUTPUT |
| diff --git a/Makefile.am b/Makefile.am |
| --- a/Makefile.am 2016-08-29 11:46:27.000000000 -0400 |
| +++ b/Makefile.am 2016-08-29 16:57:45.955528215 -0400 |
| @@ -97,16 +97,21 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SO |
| arm/filter_neon.S arm/filter_neon_intrinsics.c |
| endif |
| |
| if PNG_MIPS_MSA |
| libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\ |
| mips/filter_msa_intrinsics.c |
| endif |
| |
| +if PNG_INTEL_SSE |
| +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += contrib/intel/intel_init.c\ |
| + contrib/intel/filter_sse2_intrinsics.c |
| +endif |
| + |
| nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h |
| |
| libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \ |
| -version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 |
| |
| if HAVE_LD_VERSION_SCRIPT |
| # Versioned symbols and restricted exports |
| if HAVE_SOLARIS_LD |
| diff --git a/pngpriv.h b/pngpriv.h |
| --- debug16/pngpriv.h 2016-08-30 10:46:36.000000000 -0400 |
| +++ libpng16/pngpriv.h 2016-08-30 11:57:25.672280202 -0400 |
| @@ -185,16 +185,52 @@ |
| #ifndef PNG_MIPS_MSA_OPT |
| # if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED) |
| # define PNG_MIPS_MSA_OPT 2 |
| # else |
| # define PNG_MIPS_MSA_OPT 0 |
| # endif |
| #endif |
| |
| +#ifndef PNG_INTEL_SSE_OPT |
| +# ifdef PNG_INTEL_SSE |
| + /* Only check for SSE if the build configuration has been modified to |
| + * enable SSE optimizations. This means that these optimizations will |
| + * be off by default. See contrib/intel for more details. |
| + */ |
| +# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \ |
| + defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \ |
| + (defined(_M_IX86_FP) && _M_IX86_FP >= 2) |
| +# define PNG_INTEL_SSE_OPT 1 |
| +# endif |
| +# endif |
| +#endif |
| + |
| +#if PNG_INTEL_SSE_OPT > 0 |
| +# ifndef PNG_INTEL_SSE_IMPLEMENTATION |
| +# if defined(__SSE4_1__) || defined(__AVX__) |
| + /* We are not actually using AVX, but checking for AVX is the best |
| + way we can detect SSE4.1 and SSSE3 on MSVC. |
| + */ |
| +# define PNG_INTEL_SSE_IMPLEMENTATION 3 |
| +# elif defined(__SSSE3__) |
| +# define PNG_INTEL_SSE_IMPLEMENTATION 2 |
| +# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \ |
| + (defined(_M_IX86_FP) && _M_IX86_FP >= 2) |
| +# define PNG_INTEL_SSE_IMPLEMENTATION 1 |
| +# else |
| +# define PNG_INTEL_SSE_IMPLEMENTATION 0 |
| +# endif |
| +# endif |
| + |
| +# if PNG_INTEL_SSE_IMPLEMENTATION > 0 |
| +# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2 |
| +# endif |
| +#endif |
| + |
| #if PNG_MIPS_MSA_OPT > 0 |
| # define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa |
| # ifndef PNG_MIPS_MSA_IMPLEMENTATION |
| # if defined(__mips_msa) |
| # if defined(__clang__) |
| # elif defined(__GNUC__) |
| # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) |
| # define PNG_MIPS_MSA_IMPLEMENTATION 2 |
| @@ -1232,16 +1268,31 @@ PNG_INTERNAL_FUNCTION(void,png_read_filt |
| PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop |
| row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop |
| row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop |
| row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| #endif |
| |
| +#if PNG_INTEL_SSE_IMPLEMENTATION > 0 |
| +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop |
| + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop |
| + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_sse2,(png_row_infop |
| + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_sse2,(png_row_infop |
| + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_sse2,(png_row_infop |
| + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop |
| + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); |
| +#endif |
| + |
| /* Choose the best filter to use and filter the row data */ |
| PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr, |
| png_row_infop row_info),PNG_EMPTY); |
| |
| #ifdef PNG_SEQUENTIAL_READ_SUPPORTED |
| PNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr, |
| png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY); |
| /* Read 'avail_out' bytes of data from the IDAT stream. If the output buffer |
| @@ -1967,16 +2018,21 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_O |
| PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon, |
| (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); |
| #endif |
| |
| #if PNG_MIPS_MSA_OPT > 0 |
| PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa, |
| (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); |
| #endif |
| + |
| +# if PNG_INTEL_SSE_IMPLEMENTATION > 0 |
| +PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2, |
| + (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); |
| +# endif |
| #endif |
| |
| PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr, |
| png_const_charp key, png_bytep new_key), PNG_EMPTY); |
| |
| /* Maintainer: Put new private prototypes here ^ */ |
| |
| #include "pngdebug.h" |