Disable SIMD Huffman encoding by default w/ SIMDe

Referring to the discussions under #838 and #250, the Huffman encoding
SIMD modules perform worse with SIMD Everywhere than the equivalent
C/scalar modules.  wasm32 is like x32 in that it uses 32-bit pointers
and 64-bit registers, so we could address the regression with some
wasm32 engines by using a 64-bit Huffman bit buffer, but the C/scalar
modules would still perform better with Google's V8 engine.  Also, there
is no known way to address the regression with native code.

This commit default-disables SIMD Huffman encoding when libjpeg-turbo is
built with WITH_SIMDE and adds a new environment variable
(JSIMD_HUFFENC) to force-enable SIMD Huffman encoding for testing
purposes when it is default-disabled.
This commit is contained in:
DRC
2026-08-25 16:21:27 -04:00
parent 2646fa33f8
commit 5b34e095e3
5 changed files with 13 additions and 3 deletions
-1
View File
@@ -22,7 +22,6 @@
#cmakedefine HAVE_VLD1_S16_X3
#cmakedefine HAVE_VLD1_U16_X2
#cmakedefine HAVE_VLD1Q_U8_X4
#cmakedefine WITH_SIMDE
#if defined(WITH_SIMDE) && !defined(__EMSCRIPTEN__)
#define SIMDE_ENABLE_NATIVE_ALIASES
+5
View File
@@ -94,8 +94,13 @@ init_simd(j_common_ptr cinfo)
#endif
if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1"))
simd_support = 0;
#ifdef WITH_SIMDE
if (!GETENV_S(env, 2, "JSIMD_HUFFENC") && !strcmp(env, "1"))
simd_huffman = 1;
#else
if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1"))
simd_huffman = 0;
#endif
#endif
if (cinfo->is_decompressor) {
+3 -1
View File
@@ -5,7 +5,7 @@
* Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2022, 2024-2025, D. R. Commander.
* Copyright (C) 2022, 2024-2026, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -108,8 +108,10 @@ jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
memset(cinfo->master, 0, sizeof(my_comp_master));
#ifdef WITH_SIMD
cinfo->master->simd_support = JSIMD_UNDEFINED;
#ifndef WITH_SIMDE
cinfo->master->simd_huffman = 1;
#endif
#endif
}
+2
View File
@@ -75,6 +75,8 @@
#define SIMD_ARCHITECTURE @SIMD_ARCHITECTURE@
#cmakedefine WITH_SIMDE 0
#endif
#cmakedefine WITH_PROFILE
+3 -1
View File
@@ -6,7 +6,7 @@
* Lossless JPEG Modifications:
* Copyright (C) 1999, Ken Murchison.
* libjpeg-turbo Modifications:
* Copyright (C) 2016, 2022, 2024-2025, D. R. Commander.
* Copyright (C) 2016, 2022, 2024-2026, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -101,8 +101,10 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
memset(cinfo->master, 0, sizeof(my_decomp_master));
#ifdef WITH_SIMD
cinfo->master->simd_support = JSIMD_UNDEFINED;
#ifndef WITH_SIMDE
cinfo->master->simd_huffman = 1;
#endif
#endif
}