summaryrefslogtreecommitdiff
path: root/jchuff.c
diff options
context:
space:
mode:
authorJonathan Wright <jonathan.wright@arm.com>2021-01-12 11:33:28 +0000
committerJonathan Wright <jonathan.wright@arm.com>2021-01-12 13:37:36 +0000
commit518d81558c797486e125e37cb529d65b560a6ea0 (patch)
tree9672a5c5cac55fcac716ee135f4583486c67e268 /jchuff.c
parent09efc26aff7983f4377a1743a197ca3d74796d7d (diff)
Cherry-pick Arm CLZ fixes from upstream
Cherry-pick two patches from upstream that fix the Neon intrinsics Huffman encoding path and reduce the memory footprint on Windows on Arm: https://github.com/libjpeg-turbo/libjpeg-turbo/commit/d2c407995992be1f128704ae2479adfd7906c158 https://github.com/libjpeg-turbo/libjpeg-turbo/commit/74e6ea45e3547ae85cd43efcdfc24a6907a2154e Re-enable the Neon intrinsics Huffman encoding path for WoA compiled with clang-cl. Bug: 1160249 Change-Id: I0849ca54b8f4f8f38c9b293ea48c9de1c60be86f
Diffstat (limited to 'jchuff.c')
-rw-r--r--jchuff.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/jchuff.c b/jchuff.c
index 8ea48b8..e2d5772 100644
--- a/jchuff.c
+++ b/jchuff.c
@@ -44,15 +44,19 @@
* flags (this defines __thumb__).
*/
-/* NOTE: Both GCC and Clang define __GNUC__ */
-#if defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
+#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || \
+ defined(_M_ARM64)
#if !defined(__thumb__) || defined(__thumb2__)
#define USE_CLZ_INTRINSIC
#endif
#endif
#ifdef USE_CLZ_INTRINSIC
+#if defined(_MSC_VER) && !defined(__clang__)
+#define JPEG_NBITS_NONZERO(x) (32 - _CountLeadingZeros(x))
+#else
#define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
+#endif
#define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
#else
#include "jpeg_nbits_table.h"