libopenjpeg: fix Windows arm64 build

Windows 64bit arm has no __popcnt(), see
<https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics>.
Falling back to the generic code seems to be good enough for our
purposes.

Also update AUTHORS to match the changed google account email addresses
of Collabora.

Change-Id: I61510569793a3df24734c58ffaa3ffc0c2451477
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96010
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/AUTHORS b/AUTHORS
index 0405d27..4c4b287 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -36,7 +36,7 @@
 
 # BEGIN organizations section.
 Ada Logics Ltd. <*@adalogics.com>
-Collabora Ltd. <*@collabora.co.uk>
+Collabora Ltd. <*@collabora.com>
 DocsCorp Pty Ltd. <*@docscorp.com>
 Dropbox <*@dropbox.com>
 Foxit Software Inc <*@foxitsoftware.com>
diff --git a/third_party/libopenjpeg/0042-popcnt-windows-arm64.patch b/third_party/libopenjpeg/0042-popcnt-windows-arm64.patch
new file mode 100644
index 0000000..93606e3
--- /dev/null
+++ b/third_party/libopenjpeg/0042-popcnt-windows-arm64.patch
@@ -0,0 +1,22 @@
+From 098bb874db85c185e2e3598f735fece7552e6dca Mon Sep 17 00:00:00 2001
+From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com>
+Date: Mon, 16 May 2022 23:10:26 +0200
+Subject: [PATCH] Fix windows arm builds
+
+---
+ src/lib/openjp2/ht_dec.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/lib/openjp2/ht_dec.c b/src/lib/openjp2/ht_dec.c
+index 1eb4d525f..e2f3afd6a 100644
+--- a/src/lib/openjp2/ht_dec.c
++++ b/src/lib/openjp2/ht_dec.c
+@@ -69,7 +69,7 @@ static OPJ_BOOL only_cleanup_pass_is_decoded = OPJ_FALSE;
+ static INLINE
+ OPJ_UINT32 population_count(OPJ_UINT32 val)
+ {
+-#ifdef OPJ_COMPILER_MSVC
++#if defined(OPJ_COMPILER_MSVC) && (defined(_M_IX86) || defined(_M_AMD64))
+     return (OPJ_UINT32)__popcnt(val);
+ #elif (defined OPJ_COMPILER_GNUC)
+     return (OPJ_UINT32)__builtin_popcount(val);
diff --git a/third_party/libopenjpeg/README.pdfium b/third_party/libopenjpeg/README.pdfium
index 43692e1..0dc36dc 100644
--- a/third_party/libopenjpeg/README.pdfium
+++ b/third_party/libopenjpeg/README.pdfium
@@ -29,3 +29,4 @@
 0035-opj_image_data_free.patch: Use the right free function in opj_jp2_apply_pclr.
 0039-opj_mqc_renorme.patch: Remove unused opj_mqc_renorme().
 0041-remove_opj_clock.patch: Remove unused opj_clock.h include.
+0042-popcnt-windows-arm64.patch: Backport to fix Windows arm64 build.
diff --git a/third_party/libopenjpeg/ht_dec.c b/third_party/libopenjpeg/ht_dec.c
index 1eb4d52..e2f3afd 100644
--- a/third_party/libopenjpeg/ht_dec.c
+++ b/third_party/libopenjpeg/ht_dec.c
@@ -69,7 +69,7 @@
 static INLINE
 OPJ_UINT32 population_count(OPJ_UINT32 val)
 {
-#ifdef OPJ_COMPILER_MSVC
+#if defined(OPJ_COMPILER_MSVC) && (defined(_M_IX86) || defined(_M_AMD64))
     return (OPJ_UINT32)__popcnt(val);
 #elif (defined OPJ_COMPILER_GNUC)
     return (OPJ_UINT32)__builtin_popcount(val);