Skip to content

Commit 1383f9b

Browse files
committed
All wasm code was tested except for NLT.
1 parent f37ae83 commit 1383f9b

File tree

6 files changed

+25
-13
lines changed

6 files changed

+25
-13
lines changed

src/core/codestream/ojph_codestream_wasm.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ namespace ojph {
8787
v128_t zero = wasm_i32x4_splat(0);
8888
v128_t one = wasm_i32x4_splat(1);
8989
v128_t tmax = wasm_v128_load(max_val);
90-
v128_t *p = (v128_t*)sp;
91-
for (ui32 i = 0; i < count; i += 4, p += 1, dp += 4)
90+
si32 *p = (si32*)sp;
91+
for (ui32 i = 0; i < count; i += 4, p += 4, dp += 4)
9292
{
9393
v128_t v = wasm_v128_load(p);
9494
v128_t sign = wasm_i32x4_lt(v, zero);
@@ -192,7 +192,7 @@ namespace ojph {
192192
si64 *p = (si64*)sp;
193193
for (ui32 i = 0; i < count; i += 2, p += 2, dp += 2)
194194
{
195-
v128_t v = wasm_v128_load((v128_t*)sp);
195+
v128_t v = wasm_v128_load(p);
196196
v128_t sign = wasm_i64x2_lt(v, zero);
197197
v128_t val = wasm_v128_xor(v, sign); // negate 1's complement
198198
v128_t ones = wasm_v128_and(sign, one);
@@ -204,7 +204,7 @@ namespace ojph {
204204
wasm_v128_store(dp, val);
205205
}
206206
wasm_v128_store(max_val, tmax);
207-
}
207+
}
208208

209209
//////////////////////////////////////////////////////////////////////////
210210
void wasm_rev_tx_from_cb64(const ui64 *sp, void *dp, ui32 K_max,

src/core/common/ojph_arch.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,15 @@ namespace ojph {
286286
////////////////////////////////////////////////////////////////////////////
287287
// constants
288288
////////////////////////////////////////////////////////////////////////////
289-
const ui32 byte_alignment = 64; // 64 bytes == 512 bits
290-
const ui32 log_byte_alignment = 31 - count_leading_zeros(byte_alignment);
291-
const ui32 object_alignment = 8;
289+
#ifndef OJPH_EMSCRIPTEN
290+
const ui32 byte_alignment = 64; // 64 bytes == 512 bits
291+
const ui32 log_byte_alignment = 31 - count_leading_zeros(byte_alignment);
292+
const ui32 object_alignment = 8;
293+
#else
294+
const ui32 byte_alignment = 16; // 16 bytes == 128 bits
295+
const ui32 log_byte_alignment = 31 - count_leading_zeros(byte_alignment);
296+
const ui32 object_alignment = 8;
297+
#endif
292298

293299
////////////////////////////////////////////////////////////////////////////
294300
// templates for alignment

src/core/transform/ojph_colour_wasm.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ namespace ojph {
8383

8484
t = wasm_i64x2_extend_high_i32x4(s);
8585
t = wasm_i64x2_add(t, sh);
86-
wasm_v128_store(dp + 1, t);
86+
wasm_v128_store(dp + 2, t);
8787
}
8888
}
8989
}
@@ -99,7 +99,7 @@ namespace ojph {
9999
v128_t s0, s1;
100100
s0 = wasm_v128_load(sp);
101101
s0 = wasm_i64x2_add(s0, sh);
102-
s1 = wasm_v128_load(sp + 1);
102+
s1 = wasm_v128_load(sp + 2);
103103
s1 = wasm_i64x2_add(s1, sh);
104104
s0 = wasm_i32x4_shuffle(s0, s1, 0, 2, 4 + 0, 4 + 2);
105105
wasm_v128_store(dp, s0);
@@ -160,7 +160,7 @@ namespace ojph {
160160
u = wasm_v128_andnot(c, u); // keep only +ve or 0
161161
u = wasm_v128_or(u, v_m_sh); // combine
162162

163-
wasm_v128_store(dp + 1, u);
163+
wasm_v128_store(dp + 2, u);
164164
}
165165
}
166166
}
@@ -184,7 +184,7 @@ namespace ojph {
184184
p = wasm_v128_andnot(m, s); // +ve
185185
t0 = wasm_v128_or(n, p);
186186

187-
s = wasm_v128_load(sp + 1);
187+
s = wasm_v128_load(sp + 2);
188188
m = wasm_i64x2_lt(s, zero); // 64b -1 for -ve value
189189
tm = wasm_i64x2_sub(sh, s); // - shift - value
190190
n = wasm_v128_and(m, tm); // -ve

src/core/transform/ojph_transform_wasm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace ojph {
108108
v128_t a = wasm_v128_load(spl);
109109
v128_t b = wasm_v128_load(sph);
110110
v128_t c = wasm_i64x2_shuffle(a, b, 0, 2 + 0);
111-
v128_t d = wasm_i64x2_shuffle(a, b, 2, 2 + 2);
111+
v128_t d = wasm_i64x2_shuffle(a, b, 1, 2 + 1);
112112
wasm_v128_store(dp, c);
113113
wasm_v128_store(dp + 2, d);
114114
}

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
include(FetchContent)
44
FetchContent_Declare(
55
googletest
6-
URL https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz
6+
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
77
EXCLUDE_FROM_ALL
88
)
99
# For Windows: Prevent overriding the parent project's compiler/linker settings

tests/test_executables.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ int execute(const std::string& cmd, std::string& result)
109109
#define COMPARE_FILES_PATH "./compare_files"
110110
#define EXPAND_EXECUTABLE "./ojph_expand"
111111
#define COMPRESS_EXECUTABLE "./ojph_compress"
112+
//#define EXPAND_EXECUTABLE "20.18.0_64bit/bin/node ./ojph_expand.js"
113+
//#define COMPRESS_EXECUTABLE "20.18.0_64bit/bin/node ./ojph_compress.js"
114+
//#define EXPAND_EXECUTABLE "node-v18.7.0-linux-x64/bin/node ./ojph_expand_simd.js"
115+
//#define COMPRESS_EXECUTABLE "node-v18.7.0-linux-x64/bin/node ./ojph_compress_simd.js"
116+
//#define EXPAND_EXECUTABLE "./../../../sde/sde64 -skx -- ./ojph_expand"
117+
//#define COMPRESS_EXECUTABLE "./../../../sde/sde64 -skx -- ./ojph_compress"
112118
#endif
113119
#define TOL_DOUBLE 0.01
114120
#define TOL_INTEGER 1

0 commit comments

Comments
 (0)