From b9d2efc629c6835a91e87ef756a4827b5afa2dc9 Mon Sep 17 00:00:00 2001 From: James Zern Date: Sat, 7 Jun 2014 12:35:47 -0700 Subject: [PATCH 1/2] rename upsampling_mips32.c to yuv_mips32.c matches yuv_sse2 added in; bdfeeba dsp/yuv: move sse2 functions to yuv_sse2.c Change-Id: I84f7d7858ca6851c956e8366a7c76b45070dcbc3 --- Android.mk | 2 +- Makefile.vc | 2 +- makefile.unix | 2 +- src/dsp/Makefile.am | 2 +- src/dsp/{upsampling_mips32.c => yuv_mips32.c} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename src/dsp/{upsampling_mips32.c => yuv_mips32.c} (100%) 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 1c2ab7df..5ea63932 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -182,10 +182,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/makefile.unix b/makefile.unix index 28462954..892d6016 100644 --- a/makefile.unix +++ b/makefile.unix @@ -118,10 +118,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..41e26bfc 100644 --- a/src/dsp/Makefile.am +++ b/src/dsp/Makefile.am @@ -24,11 +24,11 @@ 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_mips32.c COMMON_SOURCES += yuv_sse2.c COMMON_SOURCES += yuv_tables_sse2.h 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 From 6e61a3a9059bef574d9cb48f414e09714cb49a3f Mon Sep 17 00:00:00 2001 From: James Zern Date: Sat, 7 Jun 2014 19:44:08 -0700 Subject: [PATCH 2/2] configure: test for -msse2 + add a WEBP_HAVE_SSE2 to dsp.h not all 32-bit toolchain configurations will have sse2 enabled by default Change-Id: I7c675e511581f93cf55c79f960fa7efa2df4987e --- configure.ac | 6 ++++++ src/dsp/Makefile.am | 25 ++++++++++++++++++------- src/dsp/dsp.h | 6 +++++- 3 files changed, 29 insertions(+), 8 deletions(-) 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/src/dsp/Makefile.am b/src/dsp/Makefile.am index 41e26bfc..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_neon.c -COMMON_SOURCES += upsampling_sse2.c COMMON_SOURCES += yuv.c COMMON_SOURCES += yuv.h COMMON_SOURCES += yuv_mips32.c -COMMON_SOURCES += yuv_sse2.c -COMMON_SOURCES += yuv_tables_sse2.h 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