Compare commits
46 Commits
main
...
portable-i
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0d7614fddf | ||
![]() |
88692490a5 | ||
![]() |
0af22e17d6 | ||
![]() |
08af967025 | ||
![]() |
a26996116f | ||
![]() |
5505a5b107 | ||
![]() |
8ed24a564c | ||
![]() |
0e8c3004be | ||
![]() |
6fcc3a720d | ||
![]() |
2371724d79 | ||
![]() |
9d1e151bf5 | ||
![]() |
a1ab868427 | ||
![]() |
0b8ecc8cfa | ||
![]() |
c646241391 | ||
![]() |
cfaebe3e95 | ||
![]() |
c0eb3ff7d4 | ||
![]() |
415b98ffad | ||
![]() |
09bcd9a397 | ||
![]() |
e83df9d208 | ||
![]() |
3387fb6fa6 | ||
![]() |
599bddb658 | ||
![]() |
28fbe808b9 | ||
![]() |
c396e6701b | ||
![]() |
96ef09107c | ||
![]() |
bc01db116f | ||
![]() |
d2adc08095 | ||
![]() |
d6f90a3d83 | ||
![]() |
cd01fc3944 | ||
![]() |
9a1a3aa827 | ||
![]() |
9eceff25c0 | ||
![]() |
fe6184d706 | ||
![]() |
cb6c3a2a36 | ||
![]() |
ec666c7526 | ||
![]() |
bafa90ccd8 | ||
![]() |
e6e3ec335c | ||
![]() |
168a3a9e28 | ||
![]() |
ad4ca27449 | ||
![]() |
3a5528713b | ||
![]() |
b4cefba731 | ||
![]() |
440945ca57 | ||
![]() |
a37a7b00d5 | ||
![]() |
a604ab5600 | ||
![]() |
b005d916f8 | ||
![]() |
586eda373d | ||
![]() |
4026e34e3f | ||
![]() |
4b21971337 |
@ -15,7 +15,10 @@ endif
|
|||||||
# https://bugs.chromium.org/p/webp/issues/detail?id=343
|
# https://bugs.chromium.org/p/webp/issues/detail?id=343
|
||||||
ifeq ($(findstring clang,$(NDK_TOOLCHAIN_VERSION)),clang)
|
ifeq ($(findstring clang,$(NDK_TOOLCHAIN_VERSION)),clang)
|
||||||
ifeq ($(TARGET_ARCH),mips)
|
ifeq ($(TARGET_ARCH),mips)
|
||||||
WEBP_CFLAGS += -no-integrated-as
|
clang_version := $(shell $(TARGET_CC) --version)
|
||||||
|
ifneq ($(findstring clang version 3,$(clang_version)),)
|
||||||
|
WEBP_CFLAGS += -no-integrated-as
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -25,6 +28,7 @@ ifneq ($(findstring armeabi-v7a, $(TARGET_ARCH_ABI)),)
|
|||||||
# specifically.
|
# specifically.
|
||||||
NEON := c.neon
|
NEON := c.neon
|
||||||
USE_CPUFEATURES := yes
|
USE_CPUFEATURES := yes
|
||||||
|
WEBP_CFLAGS += -DHAVE_CPU_FEATURES_H
|
||||||
else
|
else
|
||||||
NEON := c
|
NEON := c
|
||||||
endif
|
endif
|
||||||
|
@ -4,6 +4,7 @@ project(libwebp C)
|
|||||||
|
|
||||||
# Options for coder / decoder executables.
|
# Options for coder / decoder executables.
|
||||||
option(WEBP_ENABLE_SIMD "Enable any SIMD optimization." ON)
|
option(WEBP_ENABLE_SIMD "Enable any SIMD optimization." ON)
|
||||||
|
option(WEBP_ENABLE_WASM "Enable WebAssembly optimizations." OFF)
|
||||||
option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." OFF)
|
option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." OFF)
|
||||||
option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." OFF)
|
option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." OFF)
|
||||||
option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." OFF)
|
option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." OFF)
|
||||||
@ -13,7 +14,7 @@ option(WEBP_BUILD_WEBP_JS "Emscripten build of webp.js." OFF)
|
|||||||
option(WEBP_EXPERIMENTAL_FEATURES "Build with experimental features." OFF)
|
option(WEBP_EXPERIMENTAL_FEATURES "Build with experimental features." OFF)
|
||||||
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." OFF)
|
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." OFF)
|
||||||
|
|
||||||
if(WEBP_BUILD_WEBP_JS)
|
if(WEBP_BUILD_WEBP_JS OR WEBP_ENABLE_WASM)
|
||||||
set(WEBP_ENABLE_SIMD OFF)
|
set(WEBP_ENABLE_SIMD OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -37,6 +38,9 @@ string(REGEX MATCH "[0-9.]+" WEBP_VERSION ${SOURCE_FILE})
|
|||||||
if(WEBP_ENABLE_SWAP_16BIT_CSP)
|
if(WEBP_ENABLE_SWAP_16BIT_CSP)
|
||||||
add_definitions(-DWEBP_SWAP_16BIT_CSP)
|
add_definitions(-DWEBP_SWAP_16BIT_CSP)
|
||||||
endif()
|
endif()
|
||||||
|
if(WEBP_ENABLE_WASM)
|
||||||
|
add_definitions(-DWEBP_USE_WASM)
|
||||||
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Android only.
|
# Android only.
|
||||||
@ -50,6 +54,7 @@ if(ANDROID)
|
|||||||
set(WEBP_DEP_INCLUDE_DIRS ${WEBP_DEP_INCLUDE_DIRS}
|
set(WEBP_DEP_INCLUDE_DIRS ${WEBP_DEP_INCLUDE_DIRS}
|
||||||
${ANDROID_NDK}/sources/android/cpufeatures
|
${ANDROID_NDK}/sources/android/cpufeatures
|
||||||
)
|
)
|
||||||
|
add_definitions(-DHAVE_CPU_FEATURES_H)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -162,9 +167,11 @@ math(EXPR WEBP_SIMD_FILES_TO_INCLUDE_RANGE
|
|||||||
foreach(I_FILE RANGE ${WEBP_SIMD_FILES_TO_INCLUDE_RANGE})
|
foreach(I_FILE RANGE ${WEBP_SIMD_FILES_TO_INCLUDE_RANGE})
|
||||||
list(GET WEBP_SIMD_FILES_TO_INCLUDE ${I_FILE} FILE)
|
list(GET WEBP_SIMD_FILES_TO_INCLUDE ${I_FILE} FILE)
|
||||||
list(GET WEBP_SIMD_FLAGS_TO_INCLUDE ${I_FILE} SIMD_COMPILE_FLAG)
|
list(GET WEBP_SIMD_FLAGS_TO_INCLUDE ${I_FILE} SIMD_COMPILE_FLAG)
|
||||||
set_source_files_properties(${FILE} PROPERTIES
|
if(NOT ${SIMD_COMPILE_FLAG} STREQUAL "NOTFOUND")
|
||||||
COMPILE_FLAGS ${SIMD_COMPILE_FLAG}
|
set_source_files_properties(${FILE} PROPERTIES
|
||||||
)
|
COMPILE_FLAGS ${SIMD_COMPILE_FLAG}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Build the executables if asked for.
|
# Build the executables if asked for.
|
||||||
@ -228,12 +235,12 @@ endif()
|
|||||||
|
|
||||||
if(WEBP_BUILD_GIF2WEBP)
|
if(WEBP_BUILD_GIF2WEBP)
|
||||||
# gif2webp
|
# gif2webp
|
||||||
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS})
|
include_directories(${WEBP_DEP_GIF_INCLUDE_DIRS})
|
||||||
parse_Makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "GIF2WEBP_SRCS"
|
parse_Makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "GIF2WEBP_SRCS"
|
||||||
"gif2webp")
|
"gif2webp")
|
||||||
add_executable(gif2webp ${GIF2WEBP_SRCS})
|
add_executable(gif2webp ${GIF2WEBP_SRCS})
|
||||||
target_link_libraries(gif2webp exampleutil imageioutil webp webpmux
|
target_link_libraries(gif2webp exampleutil imageioutil webp webpmux
|
||||||
${WEBP_DEP_IMG_LIBRARIES})
|
${WEBP_DEP_GIF_LIBRARIES})
|
||||||
install(TARGETS gif2webp RUNTIME DESTINATION bin)
|
install(TARGETS gif2webp RUNTIME DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
91
README.wasm
Normal file
91
README.wasm
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
Description:
|
||||||
|
============
|
||||||
|
|
||||||
|
This file describes the compilation of libwebp using portable intrinsics /
|
||||||
|
WebAssembly (wasm) to native targets using clang and CMake.
|
||||||
|
|
||||||
|
Prerequisites:
|
||||||
|
==============
|
||||||
|
|
||||||
|
- cmake 2.8+
|
||||||
|
|
||||||
|
- clang 3.9+ for portable intrinsics support; as wasm progresses a tip of tree
|
||||||
|
build may be necessary.
|
||||||
|
|
||||||
|
Building:
|
||||||
|
=========
|
||||||
|
|
||||||
|
- configure the project with CMake using:
|
||||||
|
|
||||||
|
$ mkdir -p build && \
|
||||||
|
cd build && \
|
||||||
|
cmake -DWEBP_BUILD_DWEBP=1 -DCMAKE_C_COMPILER=clang -DWEBP_ENABLE_WASM=1 ../
|
||||||
|
|
||||||
|
- compile dwebp using 'make'.
|
||||||
|
|
||||||
|
- Note this currently generates native executables only and is incompatible
|
||||||
|
with -DWEBP_BUILD_WEBP_JS.
|
||||||
|
|
||||||
|
Build options:
|
||||||
|
==============
|
||||||
|
|
||||||
|
- platform specific multiply high (mulhi) implementation, disabled by default.
|
||||||
|
arm: -DCMAKE_C_FLAGS='-DENABLE_NEON_BUILTIN_MULHI_INT16X8 ...'
|
||||||
|
x86: -DCMAKE_C_FLAGS='-DENABLE_X86_BUILTIN_MULHI_INT16X8 ...'
|
||||||
|
|
||||||
|
Cross compilation:
|
||||||
|
==================
|
||||||
|
|
||||||
|
- arm toolchains can be obtained from:
|
||||||
|
http://www.linaro.org/downloads/
|
||||||
|
|
||||||
|
- the android ndk can be obtained from:
|
||||||
|
https://developer.android.com/ndk/downloads/index.html
|
||||||
|
|
||||||
|
armv7:
|
||||||
|
------
|
||||||
|
|
||||||
|
Android:
|
||||||
|
$ ./android-ndk-r15b/build/tools/make_standalone_toolchain.py \
|
||||||
|
--arch arm --api 24 --stl gnustl --install-dir /opt/android-arm-24
|
||||||
|
$ mkdir -p build && cd build
|
||||||
|
$ cmake ../libwebp \
|
||||||
|
-DWEBP_BUILD_DWEBP=1 \
|
||||||
|
-DCMAKE_C_COMPILER=/opt/android-arm-24/bin/clang \
|
||||||
|
-DCMAKE_PREFIX_PATH=/opt/android-arm-24/sysroot/usr/lib \
|
||||||
|
-DCMAKE_C_FLAGS=-fPIE \
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS=-Wl,-pie \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DWEBP_ENABLE_WASM=1
|
||||||
|
|
||||||
|
Linux:
|
||||||
|
$ gcc_arm=/opt/gcc-arm; target=arm-linux-gnueabihf
|
||||||
|
$ mkdir -p build && cd build
|
||||||
|
$ cmake ../libwebp -DWEBP_BUILD_DWEBP=1 -DWEBP_ENABLE_WASM=1 \
|
||||||
|
-DCMAKE_C_COMPILER=clang \
|
||||||
|
-DCMAKE_C_FLAGS="--target=$target --gcc-toolchain=$gcc_arm --sysroot=$gcc_arm/$target/libc -march=armv7-a -mfpu=neon" \
|
||||||
|
-DCMAKE_PREFIX_PATH=$gcc_arm/$target/libc/usr
|
||||||
|
|
||||||
|
aarch64 / arm64:
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Android:
|
||||||
|
$ ./android-ndk-r15b/build/tools/make_standalone_toolchain.py \
|
||||||
|
--arch arm64 --api 24 --stl gnustl --install-dir /opt/android-arm64-24
|
||||||
|
$ mkdir -p build && cd build
|
||||||
|
$ cmake ../libwebp \
|
||||||
|
-DWEBP_BUILD_DWEBP=1 \
|
||||||
|
-DCMAKE_C_COMPILER=/opt/android-arm64-24/bin/clang \
|
||||||
|
-DCMAKE_PREFIX_PATH=/opt/android-arm64-24/sysroot/usr/lib \
|
||||||
|
-DCMAKE_C_FLAGS=-fPIE \
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS=-Wl,-pie \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DWEBP_ENABLE_WASM=1
|
||||||
|
|
||||||
|
Linux:
|
||||||
|
$ gcc_arm=/opt/gcc-aarch64; target=aarch64-linux-gnu
|
||||||
|
$ mkdir -p build && cd build
|
||||||
|
$ cmake ../libwebp -DWEBP_BUILD_DWEBP=1 -DWEBP_ENABLE_WASM=1 \
|
||||||
|
-DCMAKE_C_COMPILER=clang \
|
||||||
|
-DCMAKE_C_FLAGS="--target=$target --gcc-toolchain=$gcc_arm --sysroot=$gcc_arm/$target/libc" \
|
||||||
|
-DCMAKE_PREFIX_PATH=$gcc_arm/$target/libc/usr
|
@ -31,6 +31,11 @@ using Emscripten and CMake.
|
|||||||
- that's it! Upon completion, you should have the webp.js and
|
- that's it! Upon completion, you should have the webp.js and
|
||||||
webp.js.mem files generated.
|
webp.js.mem files generated.
|
||||||
|
|
||||||
|
- Note this generates both webp_js and webp_wasm without any SIMD enabled due
|
||||||
|
to bugs with this toolchain associated with the SSE2 code.
|
||||||
|
-DWEBP_ENABLE_WASM is currently meant to generate native (x86, arm)
|
||||||
|
executables (dwebp, cwebp) and is incompatible with -DWEBP_BUILD_WEBP_JS.
|
||||||
|
|
||||||
The callable JavaScript function is WebPToSDL(), which decodes a raw WebP
|
The callable JavaScript function is WebPToSDL(), which decodes a raw WebP
|
||||||
bitstream into a canvas. See webp_js/index.html for a simple usage sample.
|
bitstream into a canvas. See webp_js/index.html for a simple usage sample.
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ model {
|
|||||||
// Check for NEON usage.
|
// Check for NEON usage.
|
||||||
if (getTargetPlatform() == "arm" || getTargetPlatform() == "arm64") {
|
if (getTargetPlatform() == "arm" || getTargetPlatform() == "arm64") {
|
||||||
NEON = "c.neon"
|
NEON = "c.neon"
|
||||||
|
cCompiler.define "HAVE_CPU_FEATURES_H"
|
||||||
} else {
|
} else {
|
||||||
NEON = "c"
|
NEON = "c"
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ endif()
|
|||||||
# Find the standard image libraries.
|
# Find the standard image libraries.
|
||||||
set(WEBP_DEP_IMG_LIBRARIES)
|
set(WEBP_DEP_IMG_LIBRARIES)
|
||||||
set(WEBP_DEP_IMG_INCLUDE_DIRS)
|
set(WEBP_DEP_IMG_INCLUDE_DIRS)
|
||||||
foreach(I_LIB PNG JPEG TIFF GIF)
|
foreach(I_LIB PNG JPEG TIFF)
|
||||||
find_package(${I_LIB})
|
find_package(${I_LIB})
|
||||||
set(WEBP_HAVE_${I_LIB} ${${I_LIB}_FOUND})
|
set(WEBP_HAVE_${I_LIB} ${${I_LIB}_FOUND})
|
||||||
if(${I_LIB}_FOUND)
|
if(${I_LIB}_FOUND)
|
||||||
@ -74,6 +74,16 @@ foreach(I_LIB PNG JPEG TIFF GIF)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# GIF detection, gifdec isn't part of the imageio lib.
|
||||||
|
set(WEBP_DEP_GIF_LIBRARIES)
|
||||||
|
set(WEBP_DEP_GIF_INCLUDE_DIRS)
|
||||||
|
find_package(GIF)
|
||||||
|
set(WEBP_HAVE_GIF ${GIF_FOUND})
|
||||||
|
if(GIF_FOUND)
|
||||||
|
list(APPEND WEBP_DEP_GIF_LIBRARIES ${GIF_LIBRARIES})
|
||||||
|
list(APPEND WEBP_DEP_GIF_INCLUDE_DIRS ${GIF_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
## Check for specific headers.
|
## Check for specific headers.
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
|
check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
|
||||||
|
@ -85,8 +85,11 @@ foreach(I_SIMD RANGE ${WEBP_SIMD_FLAGS_RANGE})
|
|||||||
foreach(FILE ${SIMD_FILES})
|
foreach(FILE ${SIMD_FILES})
|
||||||
list(APPEND WEBP_SIMD_FILES_NOT_TO_INCLUDE ${FILE})
|
list(APPEND WEBP_SIMD_FILES_NOT_TO_INCLUDE ${FILE})
|
||||||
endforeach()
|
endforeach()
|
||||||
# Explicitly disable SIMD.
|
# Explicitly disable SIMD. Avoid this with WASM to avoid an ICE with clang:
|
||||||
if(SIMD_DISABLE_FLAGS)
|
# https://bugs.chromium.org/p/webp/issues/detail?id=350
|
||||||
|
# WASM overrides the native SIMD so building it in is harmless aside from
|
||||||
|
# binary size.
|
||||||
|
if(NOT WEBP_ENABLE_WASM AND SIMD_DISABLE_FLAGS)
|
||||||
list(GET SIMD_DISABLE_FLAGS ${I_SIMD} SIMD_COMPILE_FLAG)
|
list(GET SIMD_DISABLE_FLAGS ${I_SIMD} SIMD_COMPILE_FLAG)
|
||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
if(SIMD_COMPILE_FLAG)
|
if(SIMD_COMPILE_FLAG)
|
||||||
@ -116,3 +119,13 @@ foreach(I_SIMD RANGE ${WEBP_SIMD_FLAGS_RANGE})
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
## Add *_wasm.c files if enabled.
|
||||||
|
if(WEBP_ENABLE_WASM)
|
||||||
|
file(GLOB SIMD_FILES "${CMAKE_CURRENT_LIST_DIR}/../"
|
||||||
|
"src/dsp/*_wasm.c"
|
||||||
|
)
|
||||||
|
foreach(FILE ${SIMD_FILES})
|
||||||
|
list(APPEND WEBP_SIMD_FILES_TO_INCLUDE ${FILE})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
10
configure.ac
10
configure.ac
@ -243,9 +243,13 @@ AS_IF([test "x$enable_neon" != "xno"], [
|
|||||||
NEON_FLAGS=""],
|
NEON_FLAGS=""],
|
||||||
[AC_DEFINE(WEBP_HAVE_NEON_RTCD, [1],
|
[AC_DEFINE(WEBP_HAVE_NEON_RTCD, [1],
|
||||||
[Set to 1 if runtime detection of NEON is enabled])])])
|
[Set to 1 if runtime detection of NEON is enabled])])])
|
||||||
;;
|
|
||||||
esac
|
case "$host_os" in
|
||||||
AC_SUBST([NEON_FLAGS])])
|
*android*) AC_CHECK_HEADERS([cpu-features.h]) ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
AC_SUBST([NEON_FLAGS])])
|
||||||
|
|
||||||
dnl === CLEAR_LIBVARS([var_pfx])
|
dnl === CLEAR_LIBVARS([var_pfx])
|
||||||
dnl === Clears <var_pfx>_{INCLUDES,LIBS}.
|
dnl === Clears <var_pfx>_{INCLUDES,LIBS}.
|
||||||
|
@ -3,6 +3,7 @@ noinst_LTLIBRARIES += libwebpdsp_sse2.la libwebpdspdecode_sse2.la
|
|||||||
noinst_LTLIBRARIES += libwebpdsp_sse41.la libwebpdspdecode_sse41.la
|
noinst_LTLIBRARIES += libwebpdsp_sse41.la libwebpdspdecode_sse41.la
|
||||||
noinst_LTLIBRARIES += libwebpdsp_neon.la libwebpdspdecode_neon.la
|
noinst_LTLIBRARIES += libwebpdsp_neon.la libwebpdspdecode_neon.la
|
||||||
noinst_LTLIBRARIES += libwebpdsp_msa.la libwebpdspdecode_msa.la
|
noinst_LTLIBRARIES += libwebpdsp_msa.la libwebpdspdecode_msa.la
|
||||||
|
noinst_LTLIBRARIES += libwebpdspdecode_wasm.la
|
||||||
|
|
||||||
if BUILD_LIBWEBPDECODER
|
if BUILD_LIBWEBPDECODER
|
||||||
noinst_LTLIBRARIES += libwebpdspdecode.la
|
noinst_LTLIBRARIES += libwebpdspdecode.la
|
||||||
@ -96,6 +97,10 @@ libwebpdspdecode_msa_la_SOURCES += upsampling_msa.c
|
|||||||
libwebpdspdecode_msa_la_CPPFLAGS = $(libwebpdsp_msa_la_CPPFLAGS)
|
libwebpdspdecode_msa_la_CPPFLAGS = $(libwebpdsp_msa_la_CPPFLAGS)
|
||||||
libwebpdspdecode_msa_la_CFLAGS = $(libwebpdsp_msa_la_CFLAGS)
|
libwebpdspdecode_msa_la_CFLAGS = $(libwebpdsp_msa_la_CFLAGS)
|
||||||
|
|
||||||
|
# WASM is not fully integrated into configure; the addition here keeps source
|
||||||
|
# extraction by cmake simple.
|
||||||
|
libwebpdspdecode_wasm_la_SOURCES = dec_wasm.c
|
||||||
|
|
||||||
libwebpdsp_sse2_la_SOURCES =
|
libwebpdsp_sse2_la_SOURCES =
|
||||||
libwebpdsp_sse2_la_SOURCES += argb_sse2.c
|
libwebpdsp_sse2_la_SOURCES += argb_sse2.c
|
||||||
libwebpdsp_sse2_la_SOURCES += cost_sse2.c
|
libwebpdsp_sse2_la_SOURCES += cost_sse2.c
|
||||||
|
@ -23,11 +23,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// SSE2 detection.
|
// x86/x86-64 micro-arch detection.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// skip x86 specific code for WASM builds
|
||||||
|
#if defined(WEBP_USE_WASM)
|
||||||
// apple/darwin gcc-4.0.1 defines __PIC__, but not __pic__ with -fPIC.
|
// apple/darwin gcc-4.0.1 defines __PIC__, but not __pic__ with -fPIC.
|
||||||
#if (defined(__pic__) || defined(__PIC__)) && defined(__i386__)
|
#elif (defined(__pic__) || defined(__PIC__)) && defined(__i386__)
|
||||||
static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
|
static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
|
||||||
__asm__ volatile (
|
__asm__ volatile (
|
||||||
"mov %%ebx, %%edi\n"
|
"mov %%ebx, %%edi\n"
|
||||||
@ -63,8 +65,10 @@ static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
|
|||||||
#define GetCPUInfo __cpuid
|
#define GetCPUInfo __cpuid
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// skip xgetbv definition for WASM builds
|
||||||
|
#if defined(WEBP_USE_WASM)
|
||||||
// NaCl has no support for xgetbv or the raw opcode.
|
// NaCl has no support for xgetbv or the raw opcode.
|
||||||
#if !defined(__native_client__) && (defined(__i386__) || defined(__x86_64__))
|
#elif !defined(__native_client__) && (defined(__i386__) || defined(__x86_64__))
|
||||||
static WEBP_INLINE uint64_t xgetbv(void) {
|
static WEBP_INLINE uint64_t xgetbv(void) {
|
||||||
const uint32_t ecx = 0;
|
const uint32_t ecx = 0;
|
||||||
uint32_t eax, edx;
|
uint32_t eax, edx;
|
||||||
@ -94,7 +98,19 @@ static WEBP_INLINE uint64_t xgetbv(void) {
|
|||||||
#define xgetbv() 0U // no AVX for older x64 or unrecognized toolchains.
|
#define xgetbv() 0U // no AVX for older x64 or unrecognized toolchains.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__x86_64__) || defined(WEBP_MSC_SSE2)
|
//------------------------------------------------------------------------------
|
||||||
|
// Platform specific VP8CPUInfo functions.
|
||||||
|
//
|
||||||
|
|
||||||
|
// WASM needs to precede platform specific architecture checks as the defines
|
||||||
|
// will still be present when building this target.
|
||||||
|
#if defined(WEBP_USE_WASM)
|
||||||
|
static int wasmCPUInfo(CPUFeature feature) {
|
||||||
|
if (feature != kWASM) return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
VP8CPUInfo VP8GetCPUInfo = wasmCPUInfo;
|
||||||
|
#elif defined(__i386__) || defined(__x86_64__) || defined(WEBP_MSC_SSE2)
|
||||||
|
|
||||||
// helper function for run-time detection of slow SSSE3 platforms
|
// helper function for run-time detection of slow SSSE3 platforms
|
||||||
static int CheckSlowModel(int info) {
|
static int CheckSlowModel(int info) {
|
||||||
|
@ -700,6 +700,7 @@ extern void VP8DspInitNEON(void);
|
|||||||
extern void VP8DspInitMIPS32(void);
|
extern void VP8DspInitMIPS32(void);
|
||||||
extern void VP8DspInitMIPSdspR2(void);
|
extern void VP8DspInitMIPSdspR2(void);
|
||||||
extern void VP8DspInitMSA(void);
|
extern void VP8DspInitMSA(void);
|
||||||
|
extern void VP8DspInitWASM(void);
|
||||||
|
|
||||||
static volatile VP8CPUInfo dec_last_cpuinfo_used =
|
static volatile VP8CPUInfo dec_last_cpuinfo_used =
|
||||||
(VP8CPUInfo)&dec_last_cpuinfo_used;
|
(VP8CPUInfo)&dec_last_cpuinfo_used;
|
||||||
@ -789,6 +790,11 @@ WEBP_TSAN_IGNORE_FUNCTION void VP8DspInit(void) {
|
|||||||
if (VP8GetCPUInfo(kMSA)) {
|
if (VP8GetCPUInfo(kMSA)) {
|
||||||
VP8DspInitMSA();
|
VP8DspInitMSA();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(WEBP_USE_WASM)
|
||||||
|
if (VP8GetCPUInfo(kWASM)) {
|
||||||
|
VP8DspInitWASM();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
dec_last_cpuinfo_used = VP8GetCPUInfo;
|
dec_last_cpuinfo_used = VP8GetCPUInfo;
|
||||||
|
1618
src/dsp/dec_wasm.c
Normal file
1618
src/dsp/dec_wasm.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -38,12 +38,22 @@ extern "C" {
|
|||||||
# define LOCAL_GCC_PREREQ(maj, min) 0
|
# define LOCAL_GCC_PREREQ(maj, min) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
# define LOCAL_CLANG_VERSION ((__clang_major__ << 8) | __clang_minor__)
|
||||||
|
# define LOCAL_CLANG_PREREQ(maj, min) \
|
||||||
|
(LOCAL_CLANG_VERSION >= (((maj) << 8) | (min)))
|
||||||
|
#else
|
||||||
|
# define LOCAL_CLANG_VERSION 0
|
||||||
|
# define LOCAL_CLANG_PREREQ(maj, min) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __has_builtin
|
#ifndef __has_builtin
|
||||||
# define __has_builtin(x) 0
|
# define __has_builtin(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// for now, none of the optimizations below are available in emscripten
|
// For now, none of the optimizations below are available in emscripten.
|
||||||
#if !defined(EMSCRIPTEN)
|
// WebAssembly overrides native optimizations.
|
||||||
|
#if !(defined(EMSCRIPTEN) || defined(WEBP_USE_WASM))
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER > 1310 && \
|
#if defined(_MSC_VER) && _MSC_VER > 1310 && \
|
||||||
(defined(_M_X64) || defined(_M_IX86))
|
(defined(_M_X64) || defined(_M_IX86))
|
||||||
@ -71,18 +81,20 @@ extern "C" {
|
|||||||
#define WEBP_USE_AVX2
|
#define WEBP_USE_AVX2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__ANDROID__) && defined(__ARM_ARCH_7A__)
|
|
||||||
#define WEBP_ANDROID_NEON // Android targets that might support NEON
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The intrinsics currently cause compiler errors with arm-nacl-gcc and the
|
// The intrinsics currently cause compiler errors with arm-nacl-gcc and the
|
||||||
// inline assembly would need to be modified for use with Native Client.
|
// inline assembly would need to be modified for use with Native Client.
|
||||||
#if (defined(__ARM_NEON__) || defined(WEBP_ANDROID_NEON) || \
|
#if (defined(__ARM_NEON__) || \
|
||||||
defined(__aarch64__) || defined(WEBP_HAVE_NEON)) && \
|
defined(__aarch64__) || defined(WEBP_HAVE_NEON)) && \
|
||||||
!defined(__native_client__)
|
!defined(__native_client__)
|
||||||
#define WEBP_USE_NEON
|
#define WEBP_USE_NEON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(WEBP_USE_NEON) && defined(__ANDROID__) && \
|
||||||
|
defined(__ARM_ARCH_7A__) && defined(HAVE_CPU_FEATURES_H)
|
||||||
|
#define WEBP_ANDROID_NEON // Android targets that may have NEON
|
||||||
|
#define WEBP_USE_NEON
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_M_ARM)
|
#if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_M_ARM)
|
||||||
#define WEBP_USE_NEON
|
#define WEBP_USE_NEON
|
||||||
#define WEBP_USE_INTRINSICS
|
#define WEBP_USE_INTRINSICS
|
||||||
@ -144,7 +156,8 @@ typedef enum {
|
|||||||
kNEON,
|
kNEON,
|
||||||
kMIPS32,
|
kMIPS32,
|
||||||
kMIPSdspR2,
|
kMIPSdspR2,
|
||||||
kMSA
|
kMSA,
|
||||||
|
kWASM
|
||||||
} CPUFeature;
|
} CPUFeature;
|
||||||
// returns true if the CPU supports the feature.
|
// returns true if the CPU supports the feature.
|
||||||
typedef int (*VP8CPUInfo)(CPUFeature feature);
|
typedef int (*VP8CPUInfo)(CPUFeature feature);
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
#include "./dsp.h"
|
#include "./dsp.h"
|
||||||
|
|
||||||
// Right now, some intrinsics functions seem slower, so we disable them
|
// Right now, some intrinsics functions seem slower, so we disable them
|
||||||
// everywhere except aarch64 where the inline assembly is incompatible.
|
// everywhere except newer clang/gcc or aarch64 where the inline assembly is
|
||||||
#if defined(__aarch64__)
|
// incompatible.
|
||||||
|
#if LOCAL_CLANG_PREREQ(3,8) || LOCAL_GCC_PREREQ(4,9) || defined(__aarch64__)
|
||||||
#define WEBP_USE_INTRINSICS // use intrinsics when possible
|
#define WEBP_USE_INTRINSICS // use intrinsics when possible
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -43,7 +44,7 @@
|
|||||||
// if using intrinsics, this flag avoids some functions that make gcc-4.6.3
|
// if using intrinsics, this flag avoids some functions that make gcc-4.6.3
|
||||||
// crash ("internal compiler error: in immed_double_const, at emit-rtl.").
|
// crash ("internal compiler error: in immed_double_const, at emit-rtl.").
|
||||||
// (probably similar to gcc.gnu.org/bugzilla/show_bug.cgi?id=48183)
|
// (probably similar to gcc.gnu.org/bugzilla/show_bug.cgi?id=48183)
|
||||||
#if !(LOCAL_GCC_PREREQ(4,8) || defined(__aarch64__))
|
#if !(LOCAL_CLANG_PREREQ(3,8) || LOCAL_GCC_PREREQ(4,8) || defined(__aarch64__))
|
||||||
#define WORK_AROUND_GCC
|
#define WORK_AROUND_GCC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ WEBP_EXTERN(void) WebPSafeFree(void* const ptr);
|
|||||||
// memcpy() is the safe way of moving potentially unaligned 32b memory.
|
// memcpy() is the safe way of moving potentially unaligned 32b memory.
|
||||||
static WEBP_INLINE uint32_t WebPMemToUint32(const uint8_t* const ptr) {
|
static WEBP_INLINE uint32_t WebPMemToUint32(const uint8_t* const ptr) {
|
||||||
uint32_t A;
|
uint32_t A;
|
||||||
memcpy(&A, (const int*)ptr, sizeof(A));
|
memcpy(&A, ptr, sizeof(A));
|
||||||
return A;
|
return A;
|
||||||
}
|
}
|
||||||
static WEBP_INLINE void WebPUint32ToMem(uint8_t* const ptr, uint32_t val) {
|
static WEBP_INLINE void WebPUint32ToMem(uint8_t* const ptr, uint32_t val) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user