summaryrefslogtreecommitdiff
path: root/jcphuff.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 /jcphuff.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 'jcphuff.c')
-rw-r--r--jcphuff.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/jcphuff.c b/jcphuff.c
index a8b94be..373d71f 100644
--- a/jcphuff.c
+++ b/jcphuff.c
@@ -6,6 +6,7 @@
* libjpeg-turbo Modifications:
* Copyright (C) 2011, 2015, 2018, D. R. Commander.
* Copyright (C) 2016, 2018, Matthieu Darbois.
+ * Copyright (C) 2020, Arm Limited.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -51,15 +52,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"