diff --git a/src/core/codestream/ojph_codestream_wasm.cpp b/src/core/codestream/ojph_codestream_wasm.cpp index 8dd7649..e2cd444 100644 --- a/src/core/codestream/ojph_codestream_wasm.cpp +++ b/src/core/codestream/ojph_codestream_wasm.cpp @@ -87,8 +87,8 @@ namespace ojph { v128_t zero = wasm_i32x4_splat(0); v128_t one = wasm_i32x4_splat(1); v128_t tmax = wasm_v128_load(max_val); - v128_t *p = (v128_t*)sp; - for (ui32 i = 0; i < count; i += 4, p += 1, dp += 4) + si32 *p = (si32*)sp; + for (ui32 i = 0; i < count; i += 4, p += 4, dp += 4) { v128_t v = wasm_v128_load(p); v128_t sign = wasm_i32x4_lt(v, zero); @@ -192,7 +192,7 @@ namespace ojph { si64 *p = (si64*)sp; for (ui32 i = 0; i < count; i += 2, p += 2, dp += 2) { - v128_t v = wasm_v128_load((v128_t*)sp); + v128_t v = wasm_v128_load(p); v128_t sign = wasm_i64x2_lt(v, zero); v128_t val = wasm_v128_xor(v, sign); // negate 1's complement v128_t ones = wasm_v128_and(sign, one); @@ -204,7 +204,7 @@ namespace ojph { wasm_v128_store(dp, val); } wasm_v128_store(max_val, tmax); - } + } ////////////////////////////////////////////////////////////////////////// void wasm_rev_tx_from_cb64(const ui64 *sp, void *dp, ui32 K_max, diff --git a/src/core/common/ojph_arch.h b/src/core/common/ojph_arch.h index 8292a68..29ab7a5 100644 --- a/src/core/common/ojph_arch.h +++ b/src/core/common/ojph_arch.h @@ -286,9 +286,15 @@ namespace ojph { //////////////////////////////////////////////////////////////////////////// // constants //////////////////////////////////////////////////////////////////////////// - const ui32 byte_alignment = 64; // 64 bytes == 512 bits - const ui32 log_byte_alignment = 31 - count_leading_zeros(byte_alignment); - const ui32 object_alignment = 8; + #ifndef OJPH_EMSCRIPTEN + const ui32 byte_alignment = 64; // 64 bytes == 512 bits + const ui32 log_byte_alignment = 31 - count_leading_zeros(byte_alignment); + const ui32 object_alignment = 8; + #else + const ui32 byte_alignment = 16; // 16 bytes == 128 bits + const ui32 log_byte_alignment = 31 - count_leading_zeros(byte_alignment); + const ui32 object_alignment = 8; + #endif //////////////////////////////////////////////////////////////////////////// // templates for alignment diff --git a/src/core/transform/ojph_colour_wasm.cpp b/src/core/transform/ojph_colour_wasm.cpp index 9628d55..5bf6ccd 100644 --- a/src/core/transform/ojph_colour_wasm.cpp +++ b/src/core/transform/ojph_colour_wasm.cpp @@ -83,7 +83,7 @@ namespace ojph { t = wasm_i64x2_extend_high_i32x4(s); t = wasm_i64x2_add(t, sh); - wasm_v128_store(dp + 1, t); + wasm_v128_store(dp + 2, t); } } } @@ -99,7 +99,7 @@ namespace ojph { v128_t s0, s1; s0 = wasm_v128_load(sp); s0 = wasm_i64x2_add(s0, sh); - s1 = wasm_v128_load(sp + 1); + s1 = wasm_v128_load(sp + 2); s1 = wasm_i64x2_add(s1, sh); s0 = wasm_i32x4_shuffle(s0, s1, 0, 2, 4 + 0, 4 + 2); wasm_v128_store(dp, s0); @@ -160,7 +160,7 @@ namespace ojph { u = wasm_v128_andnot(c, u); // keep only +ve or 0 u = wasm_v128_or(u, v_m_sh); // combine - wasm_v128_store(dp + 1, u); + wasm_v128_store(dp + 2, u); } } } @@ -184,7 +184,7 @@ namespace ojph { p = wasm_v128_andnot(m, s); // +ve t0 = wasm_v128_or(n, p); - s = wasm_v128_load(sp + 1); + s = wasm_v128_load(sp + 2); m = wasm_i64x2_lt(s, zero); // 64b -1 for -ve value tm = wasm_i64x2_sub(sh, s); // - shift - value n = wasm_v128_and(m, tm); // -ve diff --git a/src/core/transform/ojph_transform_wasm.cpp b/src/core/transform/ojph_transform_wasm.cpp index e308559..341cfc3 100644 --- a/src/core/transform/ojph_transform_wasm.cpp +++ b/src/core/transform/ojph_transform_wasm.cpp @@ -108,7 +108,7 @@ namespace ojph { v128_t a = wasm_v128_load(spl); v128_t b = wasm_v128_load(sph); v128_t c = wasm_i64x2_shuffle(a, b, 0, 2 + 0); - v128_t d = wasm_i64x2_shuffle(a, b, 2, 2 + 2); + v128_t d = wasm_i64x2_shuffle(a, b, 1, 2 + 1); wasm_v128_store(dp, c); wasm_v128_store(dp + 2, d); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 000409f..8cc1d72 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz + URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz EXCLUDE_FROM_ALL ) # For Windows: Prevent overriding the parent project's compiler/linker settings diff --git a/tests/test_executables.cpp b/tests/test_executables.cpp index 9f77f75..600ae53 100644 --- a/tests/test_executables.cpp +++ b/tests/test_executables.cpp @@ -109,6 +109,12 @@ int execute(const std::string& cmd, std::string& result) #define COMPARE_FILES_PATH "./compare_files" #define EXPAND_EXECUTABLE "./ojph_expand" #define COMPRESS_EXECUTABLE "./ojph_compress" +//#define EXPAND_EXECUTABLE "20.18.0_64bit/bin/node ./ojph_expand.js" +//#define COMPRESS_EXECUTABLE "20.18.0_64bit/bin/node ./ojph_compress.js" +//#define EXPAND_EXECUTABLE "node-v18.7.0-linux-x64/bin/node ./ojph_expand_simd.js" +//#define COMPRESS_EXECUTABLE "node-v18.7.0-linux-x64/bin/node ./ojph_compress_simd.js" +//#define EXPAND_EXECUTABLE "./../../../sde/sde64 -skx -- ./ojph_expand" +//#define COMPRESS_EXECUTABLE "./../../../sde/sde64 -skx -- ./ojph_compress" #endif #define TOL_DOUBLE 0.01 #define TOL_INTEGER 1