diff --git a/Android.mk b/Android.mk index 1ae1a4a6..b63e412e 100644 --- a/Android.mk +++ b/Android.mk @@ -49,10 +49,10 @@ LOCAL_SRC_FILES := \ src/dsp/lossless_neon.$(NEON) \ src/dsp/lossless_sse2.c \ src/dsp/upsampling.c \ - src/dsp/upsampling_mips32.c \ src/dsp/upsampling_neon.$(NEON) \ src/dsp/upsampling_sse2.c \ src/dsp/yuv.c \ + src/dsp/yuv_mips32.c \ src/dsp/yuv_sse2.c \ src/enc/alpha.c \ src/enc/analysis.c \ diff --git a/Makefile.vc b/Makefile.vc index c9357ba2..412e1e7e 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -183,10 +183,10 @@ DSP_DEC_OBJS = \ $(DIROBJ)\dsp\lossless_neon.obj \ $(DIROBJ)\dsp\lossless_sse2.obj \ $(DIROBJ)\dsp\upsampling.obj \ - $(DIROBJ)\dsp\upsampling_mips32.obj \ $(DIROBJ)\dsp\upsampling_neon.obj \ $(DIROBJ)\dsp\upsampling_sse2.obj \ $(DIROBJ)\dsp\yuv.obj \ + $(DIROBJ)\dsp\yuv_mips32.obj \ $(DIROBJ)\dsp\yuv_sse2.obj \ DSP_ENC_OBJS = \ diff --git a/configure.ac b/configure.ac index 1c5395ff..e88e5b41 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,12 @@ AS_IF([test -n "$AVX2_FLAGS"], [ [Set to 1 if AVX2 is supported])]) AC_SUBST([AVX2_FLAGS]) +TEST_AND_ADD_CFLAGS([SSE2_FLAGS], [-msse2]) +AS_IF([test -n "$SSE2_FLAGS"], [ + AC_DEFINE(WEBP_HAVE_SSE2, [1], + [Set to 1 if SSE2 is supported])]) +AC_SUBST([SSE2_FLAGS]) + dnl === CLEAR_LIBVARS([var_pfx]) dnl === Clears _{INCLUDES,LIBS}. AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""]) diff --git a/makefile.unix b/makefile.unix index 5e2ed162..7a2321e2 100644 --- a/makefile.unix +++ b/makefile.unix @@ -119,10 +119,10 @@ DSP_DEC_OBJS = \ src/dsp/lossless_neon.o \ src/dsp/lossless_sse2.o \ src/dsp/upsampling.o \ - src/dsp/upsampling_mips32.o \ src/dsp/upsampling_neon.o \ src/dsp/upsampling_sse2.o \ src/dsp/yuv.o \ + src/dsp/yuv_mips32.o \ src/dsp/yuv_sse2.o \ DSP_ENC_OBJS = \ diff --git a/src/dsp/Makefile.am b/src/dsp/Makefile.am index 5ea3fcc0..109fbad9 100644 --- a/src/dsp/Makefile.am +++ b/src/dsp/Makefile.am @@ -1,5 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src noinst_LTLIBRARIES = libwebpdsp.la libwebpdsp_avx2.la +noinst_LTLIBRARIES += libwebpdsp_sse2.la libwebpdspdecode_sse2.la if BUILD_LIBWEBPDECODER noinst_LTLIBRARIES += libwebpdspdecode.la @@ -15,34 +16,43 @@ COMMON_SOURCES += dec.c COMMON_SOURCES += dec_clip_tables.c COMMON_SOURCES += dec_mips32.c COMMON_SOURCES += dec_neon.c -COMMON_SOURCES += dec_sse2.c COMMON_SOURCES += dsp.h COMMON_SOURCES += lossless.c COMMON_SOURCES += lossless.h COMMON_SOURCES += lossless_mips32.c COMMON_SOURCES += lossless_neon.c -COMMON_SOURCES += lossless_sse2.c COMMON_SOURCES += neon.h COMMON_SOURCES += upsampling.c -COMMON_SOURCES += upsampling_mips32.c COMMON_SOURCES += upsampling_neon.c -COMMON_SOURCES += upsampling_sse2.c COMMON_SOURCES += yuv.c COMMON_SOURCES += yuv.h -COMMON_SOURCES += yuv_sse2.c -COMMON_SOURCES += yuv_tables_sse2.h +COMMON_SOURCES += yuv_mips32.c ENC_SOURCES = ENC_SOURCES += enc.c ENC_SOURCES += enc_mips32.c ENC_SOURCES += enc_neon.c -ENC_SOURCES += enc_sse2.c libwebpdsp_avx2_la_SOURCES = libwebpdsp_avx2_la_SOURCES += enc_avx2.c libwebpdsp_avx2_la_CPPFLAGS = $(libwebpdsp_la_CPPFLAGS) libwebpdsp_avx2_la_CFLAGS = $(AM_CFLAGS) $(AVX2_FLAGS) +libwebpdspdecode_sse2_la_SOURCES = +libwebpdspdecode_sse2_la_SOURCES += dec_sse2.c +libwebpdspdecode_sse2_la_SOURCES += lossless_sse2.c +libwebpdspdecode_sse2_la_SOURCES += upsampling_sse2.c +libwebpdspdecode_sse2_la_SOURCES += yuv_sse2.c +libwebpdspdecode_sse2_la_SOURCES += yuv_tables_sse2.h +libwebpdspdecode_sse2_la_CPPFLAGS = $(libwebpdsp_sse2_la_CPPFLAGS) +libwebpdspdecode_sse2_la_CFLAGS = $(libwebpdsp_sse2_la_CFLAGS) + +libwebpdsp_sse2_la_SOURCES = +libwebpdsp_sse2_la_SOURCES += enc_sse2.c +libwebpdsp_sse2_la_CPPFLAGS = $(libwebpdsp_la_CPPFLAGS) +libwebpdsp_sse2_la_CFLAGS = $(AM_CFLAGS) $(SSE2_FLAGS) +libwebpdsp_sse2_la_LIBADD = libwebpdspdecode_sse2.la + libwebpdsp_la_SOURCES = $(COMMON_SOURCES) $(ENC_SOURCES) noinst_HEADERS = @@ -51,11 +61,12 @@ noinst_HEADERS += ../webp/decode.h libwebpdsp_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE) $(USE_SWAP_16BIT_CSP) libwebpdsp_la_LDFLAGS = -lm -libwebpdsp_la_LIBADD = libwebpdsp_avx2.la +libwebpdsp_la_LIBADD = libwebpdsp_avx2.la libwebpdsp_sse2.la if BUILD_LIBWEBPDECODER libwebpdspdecode_la_SOURCES = $(COMMON_SOURCES) libwebpdspdecode_la_CPPFLAGS = $(libwebpdsp_la_CPPFLAGS) libwebpdspdecode_la_LDFLAGS = $(libwebpdsp_la_LDFLAGS) + libwebpdspdecode_la_LIBADD = libwebpdspdecode_sse2.la endif diff --git a/src/dsp/dsp.h b/src/dsp/dsp.h index 107bc5cc..09fd524e 100644 --- a/src/dsp/dsp.h +++ b/src/dsp/dsp.h @@ -40,7 +40,11 @@ extern "C" { #define WEBP_MSC_SSE2 // Visual C++ SSE2 targets #endif -#if defined(__SSE2__) || defined(WEBP_MSC_SSE2) +// WEBP_HAVE_* are used to indicate the presence of the instruction set in dsp +// files without intrinsics, allowing the corresponding Init() to be called. +// Files containing intrinsics will need to be built targeting the instruction +// set so should succeed on one of the earlier tests. +#if defined(__SSE2__) || defined(WEBP_MSC_SSE2) || defined(WEBP_HAVE_SSE2) #define WEBP_USE_SSE2 #endif diff --git a/src/dsp/upsampling_mips32.c b/src/dsp/yuv_mips32.c similarity index 100% rename from src/dsp/upsampling_mips32.c rename to src/dsp/yuv_mips32.c