From eef903d04afc6d03f074e3630b9a04168b77d5c7 Mon Sep 17 00:00:00 2001 From: wrv Date: Mon, 3 Jun 2024 18:11:12 -0500 Subject: [PATCH 1/3] WASM: Enable 64-bit BITS caching Bug: webp:643 Change-Id: I4cf89575e0ebcfeaf9d84be8e188863657893a07 --- src/utils/bit_reader_utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/bit_reader_utils.h b/src/utils/bit_reader_utils.h index 25ff31e5..b41a7881 100644 --- a/src/utils/bit_reader_utils.h +++ b/src/utils/bit_reader_utils.h @@ -69,6 +69,8 @@ extern "C" { #define BITS 56 #elif defined(__mips__) // MIPS #define BITS 24 +#elif defined(__wasm__) // WASM +#define BITS 56 #else // reasonable default #define BITS 24 #endif From f0c53cd966878807579b90dbada173c70f180b57 Mon Sep 17 00:00:00 2001 From: wrv Date: Mon, 3 Jun 2024 18:22:31 -0500 Subject: [PATCH 2/3] WASM: don't use USE_GENERIC_TREE It is 2-4% faster to use hard-coded tree on WASM Bug: webp:643 Change-Id: I0a192fc6af210c79814a81084cd1f199714bf46c --- src/dec/tree_dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dec/tree_dec.c b/src/dec/tree_dec.c index 24346059..8093e78b 100644 --- a/src/dec/tree_dec.c +++ b/src/dec/tree_dec.c @@ -16,7 +16,8 @@ #include "src/utils/bit_reader_inl_utils.h" #if !defined(USE_GENERIC_TREE) -#if !defined(__arm__) && !defined(_M_ARM) && !WEBP_AARCH64 +#if !defined(__arm__) && !defined(_M_ARM) && !WEBP_AARCH64 && \ + !defined(__wasm__) // using a table is ~1-2% slower on ARM. Prefer the coded-tree approach then. #define USE_GENERIC_TREE 1 // ALTERNATE_CODE #else From 8a7c8dc662e6b633084321123f8e91db53e1b206 Mon Sep 17 00:00:00 2001 From: wrv Date: Mon, 3 Jun 2024 18:06:04 -0500 Subject: [PATCH 3/3] WASM: Enable VP8L_USE_FAST_LOAD It is 2-5% faster to use VP8L fast load on WASM Bug: webp:643 Change-Id: I25c30a9e6bcfc7cadd640122579eeebcb37e6fc0 --- src/utils/bit_reader_utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/bit_reader_utils.c b/src/utils/bit_reader_utils.c index a26557aa..2707420f 100644 --- a/src/utils/bit_reader_utils.c +++ b/src/utils/bit_reader_utils.c @@ -124,7 +124,8 @@ int32_t VP8GetSignedValue(VP8BitReader* const br, int bits, #if defined(__arm__) || defined(_M_ARM) || WEBP_AARCH64 || \ defined(__i386__) || defined(_M_IX86) || \ - defined(__x86_64__) || defined(_M_X64) + defined(__x86_64__) || defined(_M_X64) || \ + defined(__wasm__) #define VP8L_USE_FAST_LOAD #endif