diff options
author | Matt Sarett <msarett@google.com> | 2015-11-24 12:18:04 -0500 |
---|---|---|
committer | Matt Sarett <msarett@google.com> | 2015-11-25 11:12:32 -0500 |
commit | b3ffc5a2fb2b2f03b77b91e29d7d505340af0ecb (patch) | |
tree | dea9a192cac4f4926da05536cd98c84784ce311e | |
parent | 2a6062fe4080bf65e9c71fdfb899e7152fd1ac0d (diff) | |
download | libjpeg-turbo-b3ffc5a2fb2b2f03b77b91e29d7d505340af0ecb.tar.gz |
Compile x86 and x86-64 SIMD optimizations
Change-Id: I2aa903ea44cc3da9255543dd21a312e3dd410b8c
-rw-r--r-- | Android.mk | 43 | ||||
-rw-r--r-- | README.android | 38 | ||||
-rw-r--r-- | simd/jsimdext.inc | 8 |
3 files changed, 79 insertions, 10 deletions
@@ -38,15 +38,34 @@ LOCAL_ASFLAGS_arm64 := -fno-integrated-as # ARM v8 64-bit NEON LOCAL_SRC_FILES_arm64 += simd/jsimd_arm64_neon.S simd/jsimd_arm64.c -# TODO (msarett): x86 and x86_64 SIMD. Cross-compiling these assembly files -# on Linux for Android is very tricky. This will require a -# YASM or NASM as a dependency. -LOCAL_SRC_FILES_x86 += jsimd_none.c -LOCAL_SRC_FILES_x86_64 += jsimd_none.c - -# TODO (msarett): MIPS SIMD. This is available in upstream libjpeg-turbo, -# but has not been cherry picked into the version used by -# Android. +# x86 MMX and SSE2 +LOCAL_SRC_FILES_x86 += \ + simd/jsimd_i386.c simd/jccolor-mmx.asm simd/jccolor-sse2.asm \ + simd/jcgray-mmx.asm simd/jcgray-sse2.asm simd/jcsample-mmx.asm \ + simd/jcsample-sse2.asm simd/jdcolor-mmx.asm simd/jdcolor-sse2.asm \ + simd/jdmerge-mmx.asm simd/jdmerge-sse2.asm simd/jdsample-mmx.asm \ + simd/jdsample-sse2.asm simd/jfdctflt-3dn.asm simd/jfdctflt-sse.asm \ + simd/jfdctfst-mmx.asm simd/jfdctfst-sse2.asm simd/jfdctint-mmx.asm \ + simd/jfdctint-sse2.asm simd/jidctflt-3dn.asm simd/jidctflt-sse2.asm \ + simd/jidctflt-sse.asm simd/jidctfst-mmx.asm simd/jidctfst-sse2.asm \ + simd/jidctint-mmx.asm simd/jidctint-sse2.asm simd/jidctred-mmx.asm \ + simd/jidctred-sse2.asm simd/jquant-3dn.asm simd/jquantf-sse2.asm \ + simd/jquanti-sse2.asm simd/jquant-mmx.asm simd/jquant-sse.asm \ + simd/jsimdcpu.asm + +# x86-64 SSE2 +LOCAL_SRC_FILES_x86_64 += \ + simd/jsimd_x86_64.c simd/jccolor-sse2-64.asm simd/jcgray-sse2-64.asm \ + simd/jcsample-sse2-64.asm simd/jdcolor-sse2-64.asm \ + simd/jdmerge-sse2-64.asm simd/jdsample-sse2-64.asm \ + simd/jfdctflt-sse-64.asm simd/jfdctfst-sse2-64.asm \ + simd/jfdctint-sse2-64.asm simd/jidctflt-sse2-64.asm \ + simd/jidctfst-sse2-64.asm simd/jidctint-sse2-64.asm \ + simd/jidctred-sse2-64.asm simd/jquantf-sse2-64.asm \ + simd/jquanti-sse2-64.asm +LOCAL_ASFLAGS_x86_64 += -D__x86_64__ + +# TODO (msarett): Compile MIPS SIMD. LOCAL_SRC_FILES_mips += jsimd_none.c LOCAL_SRC_FILES_mips64 += jsimd_none.c @@ -70,6 +89,12 @@ ifneq (,$(TARGET_BUILD_APPS)) LOCAL_SDK_VERSION := 17 endif +# Turn off position independent code (PIC) warning. This is because YASM +# cannot generate position independent code. YASM is the build tool for the +# x86 and x86-64 SIMD. +LOCAL_LDFLAGS_x86 += -Wl,--no-warn-shared-textrel +LOCAL_LDFLAGS_x86_64 += -Wl,--no-warn-shared-textrel + LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) LOCAL_WHOLE_STATIC_LIBRARIES = libjpeg-turbo_static LOCAL_MODULE := libjpeg-turbo diff --git a/README.android b/README.android new file mode 100644 index 00000000..b83c4d79 --- /dev/null +++ b/README.android @@ -0,0 +1,38 @@ +Any Android specific modifications to upstream libjpeg-turbo (1.4.2) should +be listed here: + +(1) jconfig.h and jconfigint.h + +These are included upstream as jconfig.h.in and jconfigint.h.in. +We have the option autogenerate these platform/version specific files (using +the libjpeg-turbo build system) or to manually create them. + +Autogenerating these files on linux gets us most of the way, but we've needed +to add some multi-platform flexibility to the INLINE and SIZEOF_SIZE_T macros. + +(2) Partial decoding optimizations + +These have been cherry picked from upstream and will be included in the 1.5 +release. The cherry picked commits are: +90c92ed5bf98bda381fcc369f0da46837dbb8894 +fc235cfdabbcd1c915fa3a87a56d73727da2eaeb +9bafc6a7ffa62ed7109314cbb66085075cd1c334 +3fb56e969c890e6aa7b044eea7e24751ab6f4e97 +e67a7e37deb26db5ac7da420560d22e1ca7ea4b4 +f8a1775eab51fb0a83e82343d2eae8cf52b16124 +15884f48eb1a4acd9c6c24291db974c596e71934 +ac30a1bf12751bd82e56158eb9456a28d9c086f3 + +(3) simd/jsimdext.inc + +The modification enables us to compile x86 SIMD. + +The original code was: +%define EXTN(name) _ %+ name +The new code is: +%define EXTN(name) name + +It is unclear why the unmodified code from upstream appends an underscore +to name. Before removing the underscore, the code failed to link because +the function names in the SIMD code did not match the callers (because of +the extra underscore). diff --git a/simd/jsimdext.inc b/simd/jsimdext.inc index e1442de1..92f3b041 100644 --- a/simd/jsimdext.inc +++ b/simd/jsimdext.inc @@ -179,7 +179,13 @@ section .note.GNU-stack noalloc noexec nowrite progbits ; External Symbol Name ; %ifndef EXTN -%define EXTN(name) _ %+ name ; foo() -> _foo +# Android Modification: +# The unmodified code from upstream appends an underscore to the front of +# "name" here. It is unclear why. Before removing the underscore, the +# code failed to link because the function names in the SIMD code did not +# match the callers (because of the extra underscore). This fix only +# applies to x86 SIMD code. x86_64 is handled properly by the code above. +%define EXTN(name) name %endif ; -------------------------------------------------------------------------- |