SDL_image: stb_image support: enable the ARM NEON option

From 01a2a971dd8b48e0b63dd809ee7aa1e899486ac6 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 30 May 2022 23:00:28 +0300
Subject: [PATCH] stb_image support: enable the ARM NEON option

Closes https://github.com/libsdl-org/SDL_image/issues/273
---
 IMG_stb.c   | 3 +++
 stb_image.h | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/IMG_stb.c b/IMG_stb.c
index dc6247f8..95150b42 100644
--- a/IMG_stb.c
+++ b/IMG_stb.c
@@ -46,6 +46,9 @@
 #define STB_IMAGE_STATIC
 #define STBI_NO_THREAD_LOCALS
 #define STBI_FAILURE_USERMSG
+#if defined(__ARM_NEON)
+#define STBI_NEON
+#endif
 #define STBI_NO_STDIO
 #define STBI_ONLY_PNG
 #define STBI_ONLY_JPEG
diff --git a/stb_image.h b/stb_image.h
index 13d51a4d..c95d28f5 100644
--- a/stb_image.h
+++ b/stb_image.h
@@ -3884,9 +3884,11 @@ static void stbi__setup_jpeg(stbi__jpeg *j)
 #endif
 
 #ifdef STBI_NEON
+  if (SDL_HasNEON()) { /* SDL_image change */
    j->idct_block_kernel = stbi__idct_simd;
    j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
    j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
+  } /**/
 #endif
 }