Build: Fix test failures w/ Arm Neon SIMD exts

Regression caused by
a46c111d9f3642f0ef3819e7298846ccc61869e0

Because of 7723d7f7d0aa40349d5bdd1fbe4f8631fd5a2b57, which was
introduced in libjpeg-turbo 1.5.1 in response to #81, merged upsampling/
color conversion is disabled on platforms that have SIMD-accelerated
YCbCr -> RGB color conversion but not SIMD-accelerated merged
upsampling/color conversion.  This was intended to improve performance
with the Neon SIMD extensions, since those are the only SIMD extensions
for which those circumstances apply.  Under normal circumstances, the
separate "plain" (non-fancy) upsampling and color conversion routines
will produce bitwise-identical output to the merged upsampling/color
conversion routines, but that is not the case when skipping scanlines
starting at an odd-numbered scanline.  The modified test introduced in
a46c111d9f3642f0ef3819e7298846ccc61869e0 does precisely that in order to
validate the fixes introduced in
9120a247436e84c0b4eea828cb11e8f665fcde30 and
a46c111d9f3642f0ef3819e7298846ccc61869e0.

Because of 7723d7f7d0aa40349d5bdd1fbe4f8631fd5a2b57, the segfault fixed
in 9120a247436e84c0b4eea828cb11e8f665fcde30 and
a46c111d9f3642f0ef3819e7298846ccc61869e0 didn't affect the Neon SIMD
extensions, so this commit effectively reverts the test modifications in
a46c111d9f3642f0ef3819e7298846ccc61869e0 when using those SIMD
extensions.  We can get rid of this hack, as well as
7723d7f7d0aa40349d5bdd1fbe4f8631fd5a2b57, once a Neon implementation of
merged upsampling/color conversion is available.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94efdcc..7dea737 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -774,7 +774,29 @@
   set(MD5_PPM_3x2_IFAST fd283664b3b49127984af0a7f118fccd)
   set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
   set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
-  set(MD5_PPM_420M_IFAST_ARI 57251da28a35b46eecb7177d82d10e0e)
+  # Since v1.5.1, libjpeg-turbo uses the separate non-fancy upsampling and
+  # YCbCr -> RGB color conversion routines rather than merged upsampling/color
+  # conversion when fancy upsampling is disabled on platforms that have a SIMD
+  # implementation of YCbCr -> RGB color conversion but no SIMD implementation
+  # of merged upsampling/color conversion.  This was intended to improve the
+  # performance of the Arm Neon SIMD extensions, the only SIMD extensions for
+  # which those circumstances currently apply.  The separate non-fancy
+  # upsampling and color conversion routines usually produce bitwise-identical
+  # output to the merged upsampling/color conversion routines, but that is not
+  # the case when skipping scanlines starting at an odd-numbered scanline.  In
+  # libjpeg-turbo 2.0.5 and prior, doing that while using merged h2v2
+  # upsampling caused a segfault, so this test validates the fix for that
+  # segfault.  Unfortunately, however, the test also produces different bitwise
+  # output when using the Neon SIMD extensions, because of the aforementioned
+  # optimization.  The easiest workaround is to use the old test from
+  # libjpeg-turbo 2.0.5 and prior when using the Neon SIMD extensions.  The
+  # aforementioned segfault never would have occurred with the Neon SIMD
+  # extensions anyhow, since merged upsampling is disabled when using them.
+  if((CPU_TYPE STREQUAL "arm64" OR CPU_TYPE STREQUAL "arm") AND WITH_SIMD)
+    set(MD5_PPM_420M_IFAST_ARI 72b59a99bcf1de24c5b27d151bde2437)
+  else()
+    set(MD5_PPM_420M_IFAST_ARI 57251da28a35b46eecb7177d82d10e0e)
+  endif()
   set(MD5_JPEG_420_ISLOW 9a68f56bc76e466aa7e52f415d0f4a5f)
   set(MD5_PPM_420M_ISLOW_2_1 9f9de8c0612f8d06869b960b05abf9c9)
   set(MD5_PPM_420M_ISLOW_15_8 b6875bc070720b899566cc06459b63b7)
@@ -1165,9 +1187,17 @@
 
   if(WITH_ARITH_DEC)
     # CC: RGB->YCC  SAMP: h2v2 merged  IDCT: ifast  ENT: arith
-    add_bittest(djpeg 420m-ifast-ari "-fast;-skip;1,20;-ppm"
-      testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg
-      ${MD5_PPM_420M_IFAST_ARI})
+    if((CPU_TYPE STREQUAL "arm64" OR CPU_TYPE STREQUAL "arm") AND WITH_SIMD)
+      # Refer to the comment above the definition of MD5_PPM_420M_IFAST_ARI for
+      # an explanation of why this is necessary.
+      add_bittest(djpeg 420m-ifast-ari "-fast;-ppm"
+        testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg
+        ${MD5_PPM_420M_IFAST_ARI})
+    else()
+      add_bittest(djpeg 420m-ifast-ari "-fast;-skip;1,20;-ppm"
+        testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg
+        ${MD5_PPM_420M_IFAST_ARI})
+    endif()
 
     add_bittest(jpegtran 420-islow ""
       testout_420_islow.jpg ${TESTIMAGES}/testimgari.jpg