1diff --git libpng-1.6.22-orig/configure.ac libpng-1.6.22/configure.ac 2--- libpng-1.6.22-orig/configure.ac 2016-05-25 18:59:10.000000000 -0400 3+++ libpng-1.6.22/configure.ac 2016-05-25 19:48:10.631751170 -0400 4@@ -341,16 +341,50 @@ AC_ARG_ENABLE([arm-neon], 5 6 AM_CONDITIONAL([PNG_ARM_NEON], 7 [test "$enable_arm_neon" != 'no' && 8 case "$host_cpu" in 9 arm*|aarch64*) :;; 10 *) test "$enable_arm_neon" != '';; 11 esac]) 12 13+# INTEL 14+# ===== 15+# 16+# INTEL SSE (SIMD) support. 17+ 18+AC_ARG_ENABLE([intel-sse], 19+ AS_HELP_STRING([[[--enable-intel-sse]]], 20+ [Enable Intel SSE optimizations: =no/off, yes/on:] 21+ [no/off: disable the optimizations;] 22+ [yes/on: enable the optimizations.] 23+ [If not specified: determined by the compiler.]), 24+ [case "$enableval" in 25+ no|off) 26+ # disable the default enabling: 27+ AC_DEFINE([PNG_INTEL_SSE_OPT], [0], 28+ [Disable Intel SSE optimizations]) 29+ # Prevent inclusion of the assembler files below: 30+ enable_intel_sse=no;; 31+ yes|on) 32+ AC_DEFINE([PNG_INTEL_SSE_OPT], [1], 33+ [Enable Intel SSE optimizations]);; 34+ *) 35+ AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value]) 36+ esac]) 37+ 38+# Add Intel specific files to all builds where the host_cpu is Intel ('x86*') 39+# or where Intel optimizations were explicitly requested (this allows a 40+# fallback if a future host CPU does not match 'x86*') 41+AM_CONDITIONAL([PNG_INTEL_SSE], 42+ [test "$enable_intel_sse" != 'no' && 43+ case "$host_cpu" in 44+ i?86|x86_64) :;; 45+ *) test "$enable_intel_sse" != '';; 46+ esac]) 47 AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) 48 49 # Config files, substituting as above 50 AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in]) 51 AC_CONFIG_FILES([libpng-config:libpng-config.in], 52 [chmod +x libpng-config]) 53 54 AC_OUTPUT 55diff --git libpng-1.6.22-orig/Makefile.am libpng-1.6.22/Makefile.am 56--- libpng-1.6.22-orig/Makefile.am 2016-05-17 18:15:12.000000000 -0400 57+++ libpng-1.6.22/Makefile.am 2016-05-25 19:48:10.631751170 -0400 58@@ -89,16 +89,20 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SO 59 pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\ 60 png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa 61 62 if PNG_ARM_NEON 63 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\ 64 arm/filter_neon.S arm/filter_neon_intrinsics.c 65 endif 66 67+if PNG_INTEL_SSE 68+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += contrib/intel/intel_init.c\ 69+ contrib/intel/filter_sse2_intrinsics.c 70+endif 71 nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h 72 73 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \ 74 -version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 75 76 if HAVE_LD_VERSION_SCRIPT 77 # Versioned symbols and restricted exports 78 if HAVE_SOLARIS_LD 79diff --git libpng-1.6.22-orig/pngpriv.h libpng-1.6.22/pngpriv.h 80--- libpng-1.6.22-orig/pngpriv.h 2016-05-25 18:59:10.000000000 -0400 81+++ libpng-1.6.22/pngpriv.h 2016-05-25 19:48:10.635751171 -0400 82@@ -177,16 +177,52 @@ 83 # endif /* !PNG_ARM_NEON_IMPLEMENTATION */ 84 85 # ifndef PNG_ARM_NEON_IMPLEMENTATION 86 /* Use the intrinsics code by default. */ 87 # define PNG_ARM_NEON_IMPLEMENTATION 1 88 # endif 89 #endif /* PNG_ARM_NEON_OPT > 0 */ 90 91+#ifndef PNG_INTEL_SSE_OPT 92+# ifdef PNG_INTEL_SSE 93+ /* Only check for SSE if the build configuration has been modified to 94+ * enable SSE optimizations. This means that these optimizations will 95+ * be off by default. See contrib/intel for more details. 96+ */ 97+# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \ 98+ defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \ 99+ (defined(_M_IX86_FP) && _M_IX86_FP >= 2) 100+# define PNG_INTEL_SSE_OPT 1 101+# endif 102+# endif 103+#endif 104+ 105+#if PNG_INTEL_SSE_OPT > 0 106+# ifndef PNG_INTEL_SSE_IMPLEMENTATION 107+# if defined(__SSE4_1__) || defined(__AVX__) 108+ /* We are not actually using AVX, but checking for AVX is the best 109+ way we can detect SSE4.1 and SSSE3 on MSVC. 110+ */ 111+# define PNG_INTEL_SSE_IMPLEMENTATION 3 112+# elif defined(__SSSE3__) 113+# define PNG_INTEL_SSE_IMPLEMENTATION 2 114+# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \ 115+ (defined(_M_IX86_FP) && _M_IX86_FP >= 2) 116+# define PNG_INTEL_SSE_IMPLEMENTATION 1 117+# else 118+# define PNG_INTEL_SSE_IMPLEMENTATION 0 119+# endif 120+# endif 121+ 122+# if PNG_INTEL_SSE_IMPLEMENTATION > 0 123+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2 124+# endif 125+#endif 126+ 127 /* Is this a build of a DLL where compilation of the object modules requires 128 * different preprocessor settings to those required for a simple library? If 129 * so PNG_BUILD_DLL must be set. 130 * 131 * If libpng is used inside a DLL but that DLL does not export the libpng APIs 132 * PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a 133 * static library of libpng then link the DLL against that. 134 */ 135@@ -1184,16 +1220,29 @@ PNG_INTERNAL_FUNCTION(void,png_read_filt 136 row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 137 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop 138 row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 139 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop 140 row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 141 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop 142 row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 143 144+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop 145+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 146+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop 147+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 148+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_sse2,(png_row_infop 149+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 150+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_sse2,(png_row_infop 151+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 152+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_sse2,(png_row_infop 153+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 154+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop 155+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); 156+ 157 /* Choose the best filter to use and filter the row data */ 158 PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr, 159 png_row_infop row_info),PNG_EMPTY); 160 161 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED 162 PNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr, 163 png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY); 164 /* Read 'avail_out' bytes of data from the IDAT stream. If the output buffer 165