From f9182be3c7c43c5cdf822c9e637bd480a5b96a47 Mon Sep 17 00:00:00 2001 From: Alireza Date: Thu, 9 Jul 2026 12:11:42 -0400 Subject: [PATCH 1/5] chore(openjphjs): bump extern/openjph submodule to upstream 0.30.1 Points the openjph submodule at cornerstonejs/OpenJPH#5, which rebases the fork onto upstream OpenJPH 0.30.1 (was ~22 months behind) and re-applies our custom patches. Net cornerstonejs delta from stock 0.30.1 is 3 lines in ojph_codestream_local.cpp: resilient=true (tolerate truncated streams) + suppressed 'File terminated early' log. Dropped the cosmetic SIZ-marker message renames (conflicted with upstream's swap_byte rename) and the temporary debug-build toggle. CI is the first real build/validation of this bump (not built locally). After OpenJPH#5 merges, re-point this submodule at the merge commit. --- packages/openjphjs/extern/openjph | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/openjphjs/extern/openjph b/packages/openjphjs/extern/openjph index e01c7b7..0748112 160000 --- a/packages/openjphjs/extern/openjph +++ b/packages/openjphjs/extern/openjph @@ -1 +1 @@ -Subproject commit e01c7b7f9e7ecbb15cf13bb45661c9a41ab7fec6 +Subproject commit 0748112be8820ce97a4ea3e576bd817c804737d5 From e0fb8d92a0ae84fe46aab62aa8b2c2349c049529 Mon Sep 17 00:00:00 2001 From: Alireza Date: Thu, 9 Jul 2026 12:17:35 -0400 Subject: [PATCH 2/5] fix(openjphjs): add OpenJPH 0.30.1 header dirs to the wasm target include path 0.30.1 relocated its public headers under src/core/openjph (+ src/core/shared); our glue's bare include no longer resolved and the openjphjs wasm build failed with 'ojph_arch.h file not found'. Add both 0.30.1 header roots to the openjphjs target's include path. --- packages/openjphjs/src/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/openjphjs/src/CMakeLists.txt b/packages/openjphjs/src/CMakeLists.txt index 83a9abe..64e0d18 100644 --- a/packages/openjphjs/src/CMakeLists.txt +++ b/packages/openjphjs/src/CMakeLists.txt @@ -2,6 +2,13 @@ add_executable(openjphjs jslib.cpp) target_link_libraries(openjphjs PRIVATE openjphsimd) +# OpenJPH 0.30.1 moved its public headers under src/core/openjph (and +# src/core/shared); older releases exposed them on a flatter include path, so +# our bare `#include ` no longer resolves via the linked target +# alone. Add the 0.30.1 header roots explicitly. +target_include_directories(openjphjs PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../extern/openjph/src/core/openjph + ${CMAKE_CURRENT_SOURCE_DIR}/../extern/openjph/src/core/shared) target_compile_options(openjphjs PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128) target_compile_features(openjphjs PUBLIC cxx_std_11) set_target_properties( From 40e7fd80e21355b42e90fe7d8adde0b6856f0752 Mon Sep 17 00:00:00 2001 From: Alireza Date: Thu, 9 Jul 2026 12:24:05 -0400 Subject: [PATCH 3/5] fix(openjphjs): link the OpenJPH 0.30.1 'openjph' target (was renamed from openjphsimd) 0.30.1 builds a single architecture-agnostic 'openjph' library; the old 'openjphsimd' target no longer exists, so wasm-ld failed with 'unable to find library -lopenjphsimd'. Link 'openjph', matching upstream's own wasm wrapper (subprojects/js). --- packages/openjphjs/src/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/openjphjs/src/CMakeLists.txt b/packages/openjphjs/src/CMakeLists.txt index 64e0d18..42e31f2 100644 --- a/packages/openjphjs/src/CMakeLists.txt +++ b/packages/openjphjs/src/CMakeLists.txt @@ -1,7 +1,10 @@ add_executable(openjphjs jslib.cpp) -target_link_libraries(openjphjs PRIVATE openjphsimd) +# OpenJPH 0.30.1 builds a single `openjph` library (SIMD is folded in, +# architecture-agnostic); the old separate `openjphsimd` target no longer +# exists. Upstream's own wasm wrapper links `openjph` too. +target_link_libraries(openjphjs PRIVATE openjph) # OpenJPH 0.30.1 moved its public headers under src/core/openjph (and # src/core/shared); older releases exposed them on a flatter include path, so # our bare `#include ` no longer resolves via the linked target From f918d06ed5484945d960b72f260a3b494be15059 Mon Sep 17 00:00:00 2001 From: Alireza Date: Thu, 9 Jul 2026 12:34:36 -0400 Subject: [PATCH 4/5] fix(openjphjs): keep WASM SIMD enabled for OpenJPH 0.30.1 0.30.1 deprecated OJPH_DISABLE_INTEL_SIMD and bridges it onto the new OJPH_DISABLE_SIMD; our old 'OJPH_DISABLE_INTEL_SIMD=ON' therefore disabled ALL SIMD (OJPH_ENABLE_WASM_SIMD=OFF), shipping a scalar wasm ~2x slower on decode/ encode. Stop setting the deprecated option and force OJPH_DISABLE_SIMD=OFF so 0.30.1's Emscripten path builds the WASM SIMD kernels (-msimd128). --- packages/openjphjs/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/openjphjs/CMakeLists.txt b/packages/openjphjs/CMakeLists.txt index b3a1b03..c4e3f5e 100644 --- a/packages/openjphjs/CMakeLists.txt +++ b/packages/openjphjs/CMakeLists.txt @@ -15,7 +15,13 @@ if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/openjph/CMakeLists.txt") endif() if(EMSCRIPTEN) - option(OJPH_DISABLE_INTEL_SIMD "Disables the use of SIMD instructions and associated files" ON) + # OpenJPH 0.30.1 builds WASM SIMD by default (OJPH_DISABLE_SIMD=OFF) and emits + # -msimd128 + the *_wasm.cpp kernels. Do NOT set the deprecated + # OJPH_DISABLE_INTEL_SIMD: 0.30.1 bridges it onto OJPH_DISABLE_SIMD + # (extern/openjph/CMakeLists.txt), so the old "=ON" — which used to mean + # "skip Intel SIMD, use the WASM path" — now disables ALL SIMD and ships a + # ~2x-slower scalar wasm. Keep SIMD explicitly enabled. + set(OJPH_DISABLE_SIMD OFF CACHE BOOL "Enable OpenJPH WASM SIMD" FORCE) endif() option(BUILD_SHARED_LIBS "" OFF) From dbcfbee45a77790aed33662dc5f986b2904b81ab Mon Sep 17 00:00:00 2001 From: Alireza Date: Thu, 9 Jul 2026 12:56:24 -0400 Subject: [PATCH 5/5] fix(openjphjs): build the wasm in Release, not Debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build.sh forced CMAKE_BUILD_TYPE=Debug, so the shipped openjph wasm was built -O0 with unoptimized SIMD intrinsics — the reason decode/encode benched far slower (SIMD-on was even slower than scalar under -O0) and the binary was oversized. Release (-O3) is the correct artifact and is what makes the 0.30.1 SIMD kernels fast and the wasm small. --- packages/openjphjs/build.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/openjphjs/build.sh b/packages/openjphjs/build.sh index 52d23ab..6cfa1ee 100755 --- a/packages/openjphjs/build.sh +++ b/packages/openjphjs/build.sh @@ -1,8 +1,11 @@ #!/bin/sh mkdir -p build mkdir -p dist -(cd build && CXXFLAGS=-msimd128 emcmake cmake -DCMAKE_BUILD_TYPE=Debug ..) -#(cd build && CXXFLAGS=-msimd128 emcmake cmake ..) +(cd build && CXXFLAGS=-msimd128 emcmake cmake -DCMAKE_BUILD_TYPE=Release ..) +# NOTE: this shipped a Debug (-O0) wasm until now, which left the SIMD kernels +# unoptimized (SIMD intrinsics not inlined) — making decode/encode far slower +# and the binary far larger than they should be. Release (-O3) is the correct +# artifact for a published codec. (cd build && emmake make VERBOSE=1 -j ${nprocs}) cp ./build/src/openjphjs.js ./dist cp ./build/src/openjphjs.wasm ./dist