Skip to content

Commit

Permalink
All wasm code was tested except for NLT.
Browse files Browse the repository at this point in the history
  • Loading branch information
aous72 committed Nov 8, 2024
1 parent f37ae83 commit 1383f9b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/core/codestream/ojph_codestream_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions src/core/common/ojph_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/core/transform/ojph_colour_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/transform/ojph_transform_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/test_executables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1383f9b

Please sign in to comment.