Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ option(OJPH_ENABLE_TIFF_SUPPORT "Enables input and output support for TIFF files
option(OJPH_BUILD_TESTS "Enables building test code" OFF)
option(OJPH_BUILD_EXECUTABLES "Enables building command line executables" ON)

# x86/x64-only SIMD sources must not be compiled on other architectures
set(OJPH_X86_ARCH FALSE)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|X86_64|amd64|AMD64|i[3-6]86)$")
set(OJPH_X86_ARCH TRUE)
endif()

# This is related to how the timestamp is set for URL downloaded files.
# Set DOWNLOAD_EXTRACT_TIMESTAMP
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
Expand Down Expand Up @@ -137,7 +143,7 @@ if(EMSCRIPTEN)
source_group("codestream" FILES ${CODESTREAM_WASM})
source_group("coding" FILES ${CODING_WASM})
source_group("transform" FILES ${TRANSFORM_WASM})
elseif(NOT OJPH_DISABLE_INTEL_SIMD)
elseif(NOT OJPH_DISABLE_INTEL_SIMD AND OJPH_X86_ARCH)
add_library(openjph ${SOURCES} ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2} ${CODING_SSSE3} ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2})
source_group("codestream" FILES ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2})
source_group("coding" FILES ${CODING_SSSE3})
Expand Down Expand Up @@ -170,22 +176,26 @@ else()
endif()

if (MSVC)
set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX512")
set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
if (OJPH_X86_ARCH)
set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX512")
set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
endif()
else()
set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS -mavx)
set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
set_source_files_properties(src/core/coding/ojph_block_decoder_ssse3.cpp PROPERTIES COMPILE_FLAGS -mssse3)
set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS -mavx512cd)
set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS -mavx)
set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS -mavx)
set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
if (OJPH_X86_ARCH)
set_source_files_properties(src/core/codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS -mavx)
set_source_files_properties(src/core/codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
set_source_files_properties(src/core/coding/ojph_block_decoder_ssse3.cpp PROPERTIES COMPILE_FLAGS -mssse3)
set_source_files_properties(src/core/coding/ojph_block_encoder_avx512.cpp PROPERTIES COMPILE_FLAGS -mavx512cd)
set_source_files_properties(src/core/transform/ojph_colour_avx.cpp PROPERTIES COMPILE_FLAGS -mavx)
set_source_files_properties(src/core/transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
set_source_files_properties(src/core/transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS -mavx)
set_source_files_properties(src/core/transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
endif()
endif()

############################################################
Expand Down Expand Up @@ -229,7 +239,7 @@ set(OJPH_COMPRESS src/apps/ojph_compress/ojph_compress.cpp src/apps/others/ojph_
set(OJPH_IMG_IO_SSE41 src/apps/others/ojph_img_io_sse41.cpp)
set(OJPH_IMG_IO_AVX2 src/apps/others/ojph_img_io_avx2.cpp)

if(NOT OJPH_DISABLE_INTEL_SIMD)
if(NOT OJPH_DISABLE_INTEL_SIMD AND OJPH_X86_ARCH)
list(APPEND OJPH_EXPAND ${OJPH_IMG_IO_SSE41})
list(APPEND OJPH_EXPAND ${OJPH_IMG_IO_AVX2})
list(APPEND OJPH_COMPRESS ${OJPH_IMG_IO_SSE41})
Expand All @@ -242,10 +252,14 @@ if(OJPH_BUILD_EXECUTABLES)
endif()

if (MSVC)
set_source_files_properties(src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
if (OJPH_X86_ARCH)
set_source_files_properties(src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
endif()
else()
set_source_files_properties(src/apps/others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1)
set_source_files_properties(src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
if (OJPH_X86_ARCH)
set_source_files_properties(src/apps/others/ojph_img_io_sse41.cpp PROPERTIES COMPILE_FLAGS -msse4.1)
set_source_files_properties(src/apps/others/ojph_img_io_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
endif()
endif()

if(OJPH_BUILD_EXECUTABLES)
Expand Down
6 changes: 4 additions & 2 deletions src/apps/others/ojph_img_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ namespace ojph {
converter = gen_cvrt_32b3c_to_16ub3c_be;
}

#ifndef OJPH_DISABLE_INTEL_SIMD
#if !defined(OJPH_DISABLE_INTEL_SIMD) && \
(defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64))

if (get_cpu_ext_level() >= X86_CPU_EXT_LEVEL_SSE41) {
if (bytes_per_sample == 1) {
Expand Down Expand Up @@ -503,7 +505,7 @@ namespace ojph {
}
}

#endif
#endif // x86 SIMD
}

////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 4 additions & 2 deletions src/core/codestream/ojph_codeblock_fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ namespace ojph {
}
encode_cb = ojph_encode_codeblock;

#ifndef OJPH_DISABLE_INTEL_SIMD
#if !defined(OJPH_DISABLE_INTEL_SIMD) && \
(defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64))

// Accelerated functions for INTEL/AMD CPUs
if (get_cpu_ext_level() >= X86_CPU_EXT_LEVEL_SSE)
Expand Down Expand Up @@ -166,7 +168,7 @@ namespace ojph {
encode_cb = ojph_encode_codeblock_avx512;
#endif // !OJPH_ENABLE_INTEL_AVX512

#endif // !OJPH_DISABLE_INTEL_SIMD
#endif // x86 SIMD

#else // OJPH_ENABLE_WASM_SIMD

Expand Down
4 changes: 3 additions & 1 deletion src/core/others/ojph_arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@

namespace ojph {

#ifndef OJPH_DISABLE_INTEL_SIMD
#if !defined(OJPH_DISABLE_INTEL_SIMD) && \
(defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64))

////////////////////////////////////////////////////////////////////////////
// This snippet is borrowed from Intel; see for example
Expand Down
6 changes: 4 additions & 2 deletions src/core/transform/ojph_colour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ namespace ojph {
ict_forward = gen_ict_forward;
ict_backward = gen_ict_backward;

#ifndef OJPH_DISABLE_INTEL_SIMD
#if !defined(OJPH_DISABLE_INTEL_SIMD) && \
(defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64))
int level = get_cpu_ext_level();

if (level >= X86_CPU_EXT_LEVEL_SSE)
Expand Down Expand Up @@ -144,7 +146,7 @@ namespace ojph {
rct_forward = avx2_rct_forward;
rct_backward = avx2_rct_backward;
}
#endif // !OJPH_DISABLE_INTEL_SIMD
#endif // x86 SIMD

#else // OJPH_ENABLE_WASM_SIMD
cnvrt_si32_to_si32_shftd = wasm_cnvrt_si32_to_si32_shftd;
Expand Down
6 changes: 4 additions & 2 deletions src/core/transform/ojph_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ namespace ojph {
irrev_horz_wvlt_fwd_tx = gen_irrev_horz_wvlt_fwd_tx;
irrev_horz_wvlt_bwd_tx = gen_irrev_horz_wvlt_bwd_tx;

#ifndef OJPH_DISABLE_INTEL_SIMD
#if !defined(OJPH_DISABLE_INTEL_SIMD) && \
(defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64))
int level = get_cpu_ext_level();

if (level >= X86_CPU_EXT_LEVEL_SSE)
Expand Down Expand Up @@ -165,7 +167,7 @@ namespace ojph {
rev_vert_wvlt_bwd_update = avx2_rev_vert_wvlt_bwd_update;
rev_horz_wvlt_bwd_tx = avx2_rev_horz_wvlt_bwd_tx;
}
#endif // !OJPH_DISABLE_INTEL_SIMD
#endif // x86 SIMD

#else // OJPH_ENABLE_WASM_SIMD
rev_vert_wvlt_fwd_predict = wasm_rev_vert_wvlt_fwd_predict;
Expand Down
Empty file modified subprojects/js/html/libopenjph.wasm
100755 → 100644
Empty file.
Empty file modified subprojects/js/html/libopenjph_simd.wasm
100755 → 100644
Empty file.
Loading