### Windows install to Program Files Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Install to C:\Program Files. Requires a PowerShell/CMD running as administrator. ```bash cmake --install . ``` -------------------------------- ### Install openjph CMake package and pkg-config file Source: https://github.com/aous72/openjph/blob/master/CMakeLists.txt Configures installation of the openjph CMake package files and generates a pkg-config file. Uses SameMinorVersion compatibility for the version file and handles absolute or relative install directories for pkg-config variables. ```CMake install(EXPORT openjph-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph ) include(CMakePackageConfigHelpers) configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/src/openjph-config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/openjph-config.cmake" INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph ) write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/openjph-config-version.cmake COMPATIBILITY SameMinorVersion) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openjph-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/openjph-config-version.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph ) if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") set(PKG_CONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}") else() set(PKG_CONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") endif() if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") set(PKG_CONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}") else() set(PKG_CONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}") endif() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/src/openjph.pc.in" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY ) install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig ) ``` -------------------------------- ### Install wasmer runtime with curl Source: https://github.com/aous72/openjph/blob/master/subprojects/js/standalone/README.md Install the wasmer runtime, which installs by default to '.wasmer'. The wasmer RTE can be obtained from https://github.com/wasmerio/wasmer. ```bash curl https://get.wasmer.io -sSfL | sh ``` -------------------------------- ### Include GNUInstallDirs and add subdirectories Source: https://github.com/aous72/openjph/blob/master/CMakeLists.txt Includes GNUInstallDirs for standard installation directories, then adds the src/core subdirectory. If OJPH_BUILD_EXECUTABLES is set, also adds src/apps. ```cmake include(GNUInstallDirs) add_subdirectory(src/core) if (OJPH_BUILD_EXECUTABLES) add_subdirectory(src/apps) endif() ``` -------------------------------- ### Windows install to custom folder Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Install the library to a specified folder using cmake. Use this when you want a custom installation location. ```bash cmake --install . --prefix ``` -------------------------------- ### Run demo webpage with emrun Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Starts a local webserver using the emrun command provided with Emscripten. Run from inside the html folder; the default port is 6931. ```bash emrun index.html ``` -------------------------------- ### Install openjph target and headers Source: https://github.com/aous72/openjph/blob/master/src/core/CMakeLists.txt Installs the openjph target with an export set and copies the public headers from the openjph directory to include/openjph. ```CMake install(TARGETS openjph EXPORT openjph-targets ) ``` ```CMake install(DIRECTORY openjph/ DESTINATION include/openjph FILES_MATCHING PATTERN "*.h" ) ``` -------------------------------- ### Run demo webpage with Python HTTP server Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Starts a simple Python webserver on port 8000. Run from inside the html folder, then access the page at localhost:8000. ```bash python -m http.server 8000 ``` -------------------------------- ### Run tests on Windows Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Run tests on Windows after configuring with -DOJPH_BUILD_TESTS=ON. The test setup can be finicky and may fail for silly reasons. ```bash cd tests ctest -C Release ``` -------------------------------- ### Clone OpenJPH repository Source: https://github.com/aous72/openjph/blob/master/docs/docker.md Clone the OpenJPH repository from GitHub to get the source code. ```bash https://github.com/aous72/OpenJPH.git ``` -------------------------------- ### Run tests on other platforms Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Run tests on non-Windows platforms after configuring with -DOJPH_BUILD_TESTS=ON. The test setup can be finicky and may fail for silly reasons. ```bash cd tests ctest ``` -------------------------------- ### Linux build with cmake Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Build and install on Linux. Requires libtiff to be installed first. Run from the build directory after configuring with Release build type. ```bash cd build cmake -DCMAKE_BUILD_TYPE=Release ../ make sudo make install ``` -------------------------------- ### Set library properties and include directories Source: https://github.com/aous72/openjph/blob/master/src/core/CMakeLists.txt Sets POSITION_INDEPENDENT_CODE, defines _FILE_OFFSET_BITS=64, and configures public include directories for build and install interfaces. ```cmake set_target_properties(openjph PROPERTIES POSITION_INDEPENDENT_CODE ON) target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64) target_include_directories(openjph PUBLIC $ $ $ ) ``` -------------------------------- ### Compress PPM to J2C with lossy compression Source: https://github.com/aous72/openjph/blob/master/docs/usage_examples.md Compress a PPM file to a JPEG 2000 codestream using lossy compression with specified decomposition levels, block size, precincts, progression order, colour transform, and quantization step size. On Linux and macOS, escape braces as \{ and \}. ```bash ojph_compress -i input_file.ppm -o output_file.j2c -num_decomps 5 -block_size {64,64} -precincts {128,128},{256,256} -prog_order CPRL -colour_trans true -qstep 0.05 ``` -------------------------------- ### Compress YUV to J2C with reversible compression Source: https://github.com/aous72/openjph/blob/master/docs/usage_examples.md Compress a YUV file to a JPEG 2000 codestream using reversible compression with specified dimensions, components, signedness, bit depth, and downsampling. Reversible compression does not support quantization. On Linux and macOS, escape braces as \{ and \}. ```bash ojph_compress -i input_file.yuv -o output_file.j2c -num_decomps 5 -reversible true -dims {3840,2160} -num_comps 3 -signed false -bit_depth 10 -downsamp {1,1},{2,2} ``` -------------------------------- ### Fetch googletest and jp2k_test_codestreams dependencies Source: https://github.com/aous72/openjph/blob/master/tests/CMakeLists.txt CMake configuration for the OpenJPH test suite. It fetches googletest v1.14.0 and the jp2k_test_codestreams repository. When OJPH_LOCAL_TEST is set, it overrides the fetch source directories to local paths (../../googletest and ../../jp2k_test_codestreams). For Windows, it forces gtest_force_shared_crt ON and disables BUILD_GMOCK. It also disables googletest installation and copies the local codestreams into the build directory for runtime access. ```CMake if (OJPH_LOCAL_TEST) set(FETCHCONTENT_SOURCE_DIR_GOOGLETEST "../../googletest") set(FETCHCONTENT_SOURCE_DIR_JP2K_TEST_CODESTREAMS "../../jp2k_test_codestreams") endif() # Fetch googletest include(FetchContent) FetchContent_Declare( googletest 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 set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) option(INSTALL_GTEST "Enable installation of googletest." OFF) FetchContent_MakeAvailable(googletest) # Fetch test files FetchContent_Declare( jp2k_test_codestreams URL https://github.com/aous72/jp2k_test_codestreams/archive/refs/heads/main.zip SOURCE_DIR jp2k_test_codestreams/ ) FetchContent_MakeAvailable(jp2k_test_codestreams) if (OJPH_LOCAL_TEST) # The tests look for the codestreams relative to their runtime directory # (".\\jp2k_test_codestreams\\..."), so copy the Desktop copy there. if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/jp2k_test_codestreams/openjph") execute_process( COMMAND ${CMAKE_COMMAND} -E copy_directory "${FETCHCONTENT_SOURCE_DIR_JP2K_TEST_CODESTREAMS}" "${CMAKE_CURRENT_BINARY_DIR}/jp2k_test_codestreams") endif() endif() # create the mse_pae executable include(mse_pae.cmake) # create the compare_files executable add_executable( compare_files compare_files.cpp ) ``` -------------------------------- ### File documentation with @file marker Source: https://github.com/aous72/openjph/blob/master/docs/doxygen_style.md Each file should have a file description using the `@file` marker, inserted after the license statement. Includes `@brief` and an elaborated description. ```cpp /** @file file.h * @brief A brief file description. * * A more elaborated file description. */ ``` -------------------------------- ### Compile convert_mse_pae_to_tests.cpp with g++ Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/Readme.md Compiles the helper that generates googletest tests from mse_pae.txt and ht_cmdlines.txt. The resulting executable reads mse_pae.txt in jp2k_test_streams/openjph and ht_cmdlines.txt in this folder to produce openjph_tests.cpp, whose content must be copied into ../test_executables.cpp because googletest does not support included files. ```bash g++ -g3 convert_mse_pae_to_tests.cpp -o convert_mse_pae_to_tests ``` -------------------------------- ### Windows command-line build Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Build the generated Visual Studio solution from the command line using cmake. Run from the build folder. ```bash cmake --build . --config Release ``` -------------------------------- ### Set C and C++ standards Source: https://github.com/aous72/openjph/blob/master/CMakeLists.txt Sets CMAKE_C_STANDARD to 11 if not already defined, required for aligned_alloc. Sets CMAKE_CXX_STANDARD to 14 if not defined, needed for gtest; C++11 is sufficient for the library. Prints the chosen standards. ```cmake if (NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 11) endif() message(STATUS "C Standard is set to ${CMAKE_C_STANDARD}") # C++14 is needed for gtest, otherwise, C++11 is sufficient for the library if (NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif() message(STATUS "C++ Standard is set to ${CMAKE_CXX_STANDARD}") ``` -------------------------------- ### Expand J2C to PPM and YUV Source: https://github.com/aous72/openjph/blob/master/docs/usage_examples.md Expand a JPEG 2000 codestream to PPM and YUV output files. Issuing ojph_expand without arguments prints a short usage statement. ```bash ojph_expand -i input_file.j2c -o output_file.ppm ``` ```bash ojph_expand -i input_file.j2c -o output_file.yuv ``` -------------------------------- ### Member variable documentation with //!< Source: https://github.com/aous72/openjph/blob/master/docs/doxygen_style.md Short one-line comment for member variables using `//!<` after the declaration. ```cpp int var; //! ``` -------------------------------- ### Add compiler definitions and options for MSVC, Clang/GNU, and Emscripten Source: https://github.com/aous72/openjph/blob/master/CMakeLists.txt Adds _CRT_SECURE_NO_WARNINGS for MSVC. For Clang or GNU compilers (excluding MSVC), enables -fexceptions, -Wall, -Wextra, -Wconversion, and -Wunused-parameter. For Emscripten, enables -fexceptions and optionally -DOJPH_ENABLE_WASM_SIMD -msimd128 when OJPH_ENABLE_WASM_SIMD is set. ```cmake if (MSVC) add_compile_definitions(_CRT_SECURE_NO_WARNINGS) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" AND NOT MSVC) add_compile_options( -fexceptions -Wall -Wextra -Wconversion -Wunused-parameter ) endif() if (EMSCRIPTEN) add_compile_options(-fexceptions) if(OJPH_ENABLE_WASM_SIMD) add_compile_options(-DOJPH_ENABLE_WASM_SIMD -msimd128) endif() endif() ``` -------------------------------- ### Run Docker container with volume mapping to Windows temp Source: https://github.com/aous72/openjph/blob/master/docs/docker.md Run the openjph:latest image while mapping the container's /usr/src/openjph/build directory to the local Windows C:\temp directory. ```bash docker run -it --rm -v C:\temp:/usr/src/openjph/build openjph:latest ``` -------------------------------- ### Enable testing and add tests subdirectory Source: https://github.com/aous72/openjph/blob/master/CMakeLists.txt Enables CTest and adds the tests subdirectory only when the project is the top-level project and OJPH_BUILD_TESTS is enabled. ```CMake if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND OJPH_BUILD_TESTS) enable_testing() add_subdirectory(tests) endif() ``` -------------------------------- ### Build Docker image with docker build Source: https://github.com/aous72/openjph/blob/master/docs/docker.md Build the Docker image named openjph:latest using the Dockerfile in the current directory. ```bash cd OpenJPH ``` ```bash docker build --rm -f Dockerfile -t openjph:latest . ``` -------------------------------- ### Run WASM file with wasmer Source: https://github.com/aous72/openjph/blob/master/subprojects/js/standalone/README.md Run a WASM file using the wasmer runtime. The '--dir=.' flag gives wasmer access to the current directory, and '--enable-all' enables all available WASM features. Arguments to the program are passed after '--'. ```bash ~/.wasmer/bin/wasmer run --dir=. --enable-all helloworld.wasm -- arguments ``` -------------------------------- ### Configure VSX SIMD Kernels for PowerPC64 LE Source: https://github.com/aous72/openjph/blob/master/src/core/CMakeLists.txt Adds VSX-optimized source files and sets per-file compilation flags for little-endian PowerPC64 (ppc64le) targets when SIMD is not disabled. Most kernels are built at POWER8 baseline (-mcpu=power8) for dispatch on POWER8 and newer; the block decoder is built at POWER9 (-mcpu=power9) because it is only dispatched on POWER9+ and benefits from newer instructions. Kernels are selected at run-time via get_cpu_ext_level() as noted in ojph_codeblock_fun.cpp. ```cmake if (("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_PPC64") AND (CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le|powerpc64le")) if (NOT OJPH_DISABLE_SIMD) # native 128-bit VSX kernels (see ojph_simd_vsx.h). Supported # targets are POWER8 (ISA 2.07) and newer, little-endian only. # Kernels are selected at run-time from the ISA level reported # by get_cpu_ext_level(); see ojph_codeblock_fun.cpp. # # Most kernels are built at the POWER8 baseline so that they can # be dispatched on POWER8 as well. The block decoder is the # exception: it is dispatched only on POWER9 and newer (it is # load/permute bound and does not pay off on POWER8), so it is # built at the POWER9 baseline, where lxvx/xxperm cost it about # 10% less than the ISA 2.07 sequences. Its object is never # entered on POWER8, so the newer instructions are safe. list(APPEND SOURCES ${CODESTREAM_VSX} ${CODING_VSX} ${TRANSFORM_VSX}) source_group("codestream" FILES ${CODESTREAM_VSX}) source_group("coding" FILES ${CODING_VSX}) source_group("transform" FILES ${TRANSFORM_VSX}) set_source_files_properties(codestream/ojph_codestream_vsx.cpp PROPERTIES COMPILE_FLAGS "-mcpu=power8") set_source_files_properties(coding/ojph_block_decoder_vsx.cpp PROPERTIES COMPILE_FLAGS "-mcpu=power9") set_source_files_properties(transform/ojph_transform_vsx.cpp PROPERTIES COMPILE_FLAGS "-mcpu=power8") set_source_files_properties(transform/ojph_colour_vsx.cpp PROPERTIES COMPILE_FLAGS "-mcpu=power8") endif() endif() ``` -------------------------------- ### Configure WASM SIMD and build options for Emscripten Source: https://github.com/aous72/openjph/blob/master/CMakeLists.txt Sets build options when compiling with Emscripten. Disables shared libraries, TIFF support, and stream expansion. Enables WASM SIMD by default unless OJPH_DISABLE_SIMD is set. ```cmake if(EMSCRIPTEN) set(BUILD_SHARED_LIBS OFF) set(OJPH_ENABLE_TIFF_SUPPORT OFF) set(OJPH_BUILD_STREAM_EXPAND OFF) if (OJPH_DISABLE_SIMD) set(OJPH_ENABLE_WASM_SIMD OFF) else() set(OJPH_ENABLE_WASM_SIMD ON) endif() endif() ``` -------------------------------- ### Activate Emscripten environment Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Run this command to activate the Emscripten tools before compiling. It is required for both Node.js and JavaScript/WASM compilation. ```bash source emsdk_env.sh ``` -------------------------------- ### MSVC post-build copy commands Source: https://github.com/aous72/openjph/blob/master/tests/CMakeLists.txt For MSVC builds, copies required DLLs and executables (gtest.dll, gtest_main.dll, ojph_compress, ojph_expand, openjph) to the test directory after building test_executables. Also copies compare_files.exe and mse_pae.exe from their configuration subdirectories. If OJPH_ENABLE_TIFF_SUPPORT is enabled, copies tiff.dll, tiffxx.dll, tiffd.dll, and tiffxxd.dll from the TIFF bin directory. ```cmake if (MSVC) add_custom_command(TARGET test_executables POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "../bin/\$(Configuration)/gtest.dll" "./" COMMAND ${CMAKE_COMMAND} -E copy "../bin/\$(Configuration)/gtest_main.dll" "./" COMMAND ${CMAKE_COMMAND} -E copy "$" "./" COMMAND ${CMAKE_COMMAND} -E copy "$" "./" COMMAND ${CMAKE_COMMAND} -E copy "$" "./" ) add_custom_command(TARGET compare_files POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "./\$(Configuration)/compare_files.exe" "./" ) add_custom_command(TARGET mse_pae POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "./\$(Configuration)/mse_pae.exe" "./" ) if (OJPH_ENABLE_TIFF_SUPPORT) file(COPY "${TIFF_INCLUDE_DIR}\\..\\bin\\tiff.dll" DESTINATION "./") file(COPY "${TIFF_INCLUDE_DIR}\\..\\bin\\tiffxx.dll" DESTINATION "./") file(COPY "${TIFF_INCLUDE_DIR}\\..\\bin\\tiffd.dll" DESTINATION "./") file(COPY "${TIFF_INCLUDE_DIR}\\..\\bin\\tiffxxd.dll" DESTINATION "./") endif() else() add_custom_command(TARGET test_executables POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" "./" COMMAND ${CMAKE_COMMAND} -E copy "$" "./" ) if(EMSCRIPTEN) add_custom_command(TARGET test_executables POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$/ojph_expand.wasm" "./" COMMAND ${CMAKE_COMMAND} -E copy "$/ojph_compress.wasm" "./" ) endif(EMSCRIPTEN) if(CYGWIN OR MINGW) add_custom_command(TARGET test_executables POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "../bin/${CMAKE_SHARED_LIBRARY_PREFIX}gtest.dll" "./" COMMAND ${CMAKE_COMMAND} -E copy "../bin/${CMAKE_SHARED_LIBRARY_PREFIX}gtest_main.dll" "./" COMMAND ${CMAKE_COMMAND} -E copy "$" "./" ) endif() endif(MSVC) ``` -------------------------------- ### Compile OpenJPH for Node.js with Emscripten Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Compiles the library for Node.js using Emscripten. Generates two versions of the library and executables: one with WebAssembly SIMD instructions and one without. ```bash emcmake cmake .. ``` ```bash emmake make ``` -------------------------------- ### Configure test_quant_weights target Source: https://github.com/aous72/openjph/blob/master/tests/CMakeLists.txt Defines the test_quant_weights executable from test_quant_weights.cpp for quantization weights tests. Links against openjph and GTest::gtest_main. ```cmake add_executable( test_quant_weights test_quant_weights.cpp ) target_link_libraries( test_quant_weights openjph GTest::gtest_main ) ``` -------------------------------- ### Set default build type and print sanitizer hints Source: https://github.com/aous72/openjph/blob/master/CMakeLists.txt If CMAKE_BUILD_TYPE is not set, defaults to 'Release' and prints status messages showing how to enable AddressSanitizer (asan) or UndefinedBehaviorSanitizer (ubsan) via cmake -DCMAKE_BUILD_TYPE=... . Always prints the current build type. ```cmake if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message(STATUS "To use AddressSanitizer, use \"cmake .. -DCMAKE_BUILD_TYPE=asan\"" ) message(STATUS "To use UndefinedBehaviorSanitizer, use \"cmake .. -DCMAKE_BUILD_TYPE=ubsan\"" ) endif() message(STATUS "Building ${CMAKE_BUILD_TYPE}") ``` -------------------------------- ### Compile JavaScript/WASM decoder Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Compiles the JavaScript/WASM decoder from the subprojects/js/build directory. Creates libopenjph.js, libopenjph.wasm, libopenjphsimd.js, and libopenjphsimd.wasm in subprojects/js/html. ```bash cd subprojects/js/build ``` ```bash emcmake cmake .. ``` ```bash emmake make ``` -------------------------------- ### Reversible encoding tests with tiles and decompositions Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt CMake add_test commands for reversible encoding tests using com_decom.sh -renc with tile_size {32,32} and num_decomps 5 or 6. Each test encodes mm.ppm, decodes with -precise -quiet, and compares outputs. ```CMake add_test(NAME simple_enc_rev53_64x64_tiles_33x33_d5 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -renc "-i ${images_folder}/mm.ppm -o simple_enc_rev53_64x64_tiles_33x33_d5.j2c -reversible true -tile_size \{32,32\} -num_decomps 5" "-i simple_enc_rev53_64x64_tiles_33x33_d5.j2c -o test1.ppm -precise -quiet" "-i simple_enc_rev53_64x64_tiles_33x33_d5.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` ```CMake add_test(NAME simple_enc_rev53_64x64_tiles_33x33_d6 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -renc "-i ${images_folder}/mm.ppm -o simple_enc_rev53_64x64_tiles_33x33_d6.j2c -reversible true -tile_size \{32,32\} -num_decomps 6" "-i simple_enc_rev53_64x64_tiles_33x33_d6.j2c -o test1.ppm -precise -quiet" "-i simple_enc_rev53_64x64_tiles_33x33_d6.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Reversible encoding tests with varying block sizes Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt CMake add_test commands for reversible encoding tests using com_decom.sh -renc with different block sizes. Each test encodes mm.ppm, decodes with -precise -quiet, and compares outputs. ```CMake add_test(NAME simple_enc_rev53_64x64 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -renc "-i ${images_folder}/mm.ppm -o simple_enc_rev53_64x64.j2c -reversible true" "-i simple_enc_rev53_64x64.j2c -o test1.ppm -precise -quiet" "-i simple_enc_rev53_64x64.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` ```CMake add_test(NAME simple_enc_rev53_32x32 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -renc "-i ${images_folder}/mm.ppm -o simple_enc_rev53_32x32.j2c -reversible true -block_size \{32,32\}" "-i simple_enc_rev53_32x32.j2c -o test1.ppm -precise -quiet" "-i simple_enc_rev53_32x32.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` ```CMake add_test(NAME simple_enc_rev53_4x4 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -renc "-i ${images_folder}/mm.ppm -o simple_enc_rev53_4x4.j2c -reversible true -block_size \{4,4\}" "-i simple_enc_rev53_4x4.j2c -o test1.ppm -precise -quiet" "-i simple_enc_rev53_4x4.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` ```CMake add_test(NAME simple_enc_rev53_1024x4 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -renc "-i ${images_folder}/mm.ppm -o simple_enc_rev53_1024x4.j2c -reversible true -block_size \{4,1024\}" "-i simple_enc_rev53_1024x4.j2c -o test1.ppm -precise -quiet" "-i simple_enc_rev53_1024x4.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` ```CMake add_test(NAME simple_enc_rev53_4x1024 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -renc "-i ${images_folder}/mm.ppm -o simple_enc_rev53_4x1024.j2c -reversible true -block_size \{1024,4\}" "-i simple_enc_rev53_4x1024.j2c -o test1.ppm -precise -quiet" "-i simple_enc_rev53_4x1024.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### CMakeLists.txt for ojph_stream_expand Source: https://github.com/aous72/openjph/blob/master/src/apps/ojph_stream_expand/CMakeLists.txt Builds the ojph_stream_expand executable, linking against openjph and Threads, with ws2_32 added on Windows. Sources include the app's own .cpp/.h files plus shared socket and thread implementations from ../others and ../common. ```CMake ## building ojph_stream_expand ############################## find_package(Threads) file(GLOB OJPH_STREAM_EXPAND "*.cpp" "*.h") file(GLOB OJPH_SOCKETS "../others/ojph_sockets.cpp") file(GLOB OJPH_SOCKETS_H "../common/ojph_sockets.h") file(GLOB OJPH_THREADS "../others/ojph_threads.cpp") file(GLOB OJPH_THREADS_H "../common/ojph_threads.h") list(APPEND SOURCES ${OJPH_STREAM_EXPAND} ${OJPH_SOCKETS} ${OJPH_SOCKETS_H} ${OJPH_THREADS} ${OJPH_THREADS_H}) source_group("main" FILES ${OJPH_STREAM_EXPAND}) source_group("others" FILES ${OJPH_SOCKETS} ${OJPH_THREADS}) source_group("common" FILES ${OJPH_SOCKETS_H} ${OJPH_THREADS_H}) add_executable(ojph_stream_expand ${SOURCES}) target_include_directories(ojph_stream_expand PRIVATE ../common) target_link_libraries(ojph_stream_expand PRIVATE openjph Threads::Threads) if(WIN32) target_link_libraries(ojph_stream_expand PRIVATE ws2_32) endif() install(TARGETS ojph_stream_expand) ``` -------------------------------- ### Encode with 64x64 block size Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Adds a CTest test named simple_enc_irv97_64x64 that runs com_decom.sh with -enc. It encodes mm.ppm to a .j2c file with qstep 0.1, decodes it twice (with and without -precise -quiet), and compares outputs against mm.ppm. ```CMake add_test(NAME simple_enc_irv97_64x64 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -enc "-i ${images_folder}/mm.ppm -o simple_enc_irv97_64x64.j2c -qstep 0.1" "-i simple_enc_irv97_64x64.j2c -o test1.ppm -precise -quiet" "-i simple_enc_irv97_64x64.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Build OpenJPH library with tests Source: https://github.com/aous72/openjph/blob/master/subprojects/js/standalone/README.md Build the OpenJPH library as usual with testing enabled. This is a standard build without any modifications. The modified com_decom.sh and com_decom_yuv.sh files in the tests folder should invoke the WASM versions of the code. ```bash cd build cmake -DBUILD_TESTING=yes .. make make test ``` -------------------------------- ### macOS build with Xcode generator Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Generate an Xcode project in the build folder and build/install. Not tested recently. ```bash cd build cmake ../ -G Xcode make sudo make install ``` -------------------------------- ### simple_enc_irv97_64x64_16bit CTest command Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Adds a CTest test that encodes 16-bit mm.ppm with qstep 0.01 and verifies decoding with and without -precise. ```CMake add_test(NAME simple_enc_irv97_64x64_16bit COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -enc "-i ${images_folder}/mm.ppm -o simple_enc_irv97_64x64_16bit.j2c -qstep 0.01" "-i simple_enc_irv97_64x64_16bit.j2c -o test1.ppm -precise -quiet" "-i simple_enc_irv97_64x64_16bit.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Encode with 32x32 block size Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Adds a CTest test named simple_enc_irv97_32x32 that runs com_decom.sh with -enc. It encodes mm.ppm to a .j2c file with qstep 0.01 and block_size {32,32}, decodes it twice (with and without -precise -quiet), and compares outputs against mm.ppm. ```CMake add_test(NAME simple_enc_irv97_32x32 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -enc "-i ${images_folder}/mm.ppm -o simple_enc_irv97_32x32.j2c -qstep 0.01 -block_size \{32,32\}" "-i simple_enc_irv97_32x32.j2c -o test1.ppm -precise -quiet" "-i simple_enc_irv97_32x32.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Encode with 256x16 block size Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Adds a CTest test named simple_enc_irv97_256x16 that runs com_decom.sh with -enc. It encodes mm.ppm to a .j2c file with qstep 0.01 and block_size {16,256}, decodes it twice (with and without -precise -quiet), and compares outputs against mm.ppm. ```CMake add_test(NAME simple_enc_irv97_256x16 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -enc "-i ${images_folder}/mm.ppm -o simple_enc_irv97_256x16.j2c -qstep 0.01 -block_size \{16,256\}" "-i simple_enc_irv97_256x16.j2c -o test1.ppm -precise -quiet" "-i simple_enc_irv97_256x16.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Set DOWNLOAD_EXTRACT_TIMESTAMP policy for CMake 3.24+ Source: https://github.com/aous72/openjph/blob/master/CMakeLists.txt Sets the CMP0135 policy to NEW when CMake version is 3.24.0 or greater, affecting timestamp handling for downloaded files. ```cmake if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") if(POLICY CMP0065) cmake_policy(SET CMP0135 NEW) endif() endif() ``` -------------------------------- ### Comment block format Source: https://github.com/aous72/openjph/blob/master/docs/doxygen_style.md Standard Doxygen comment block using `/** ... */` with an asterisk on each line. Prefer `@` over `\` for markers. ```cpp /** * ... comment ... */ ``` -------------------------------- ### Encode with 16x16 block size Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Adds a CTest test named simple_enc_irv97_16x16 that runs com_decom.sh with -enc. It encodes mm.ppm to a .j2c file with qstep 0.01 and block_size {16,16}, decodes it twice (with and without -precise -quiet), and compares outputs against mm.ppm. ```CMake add_test(NAME simple_enc_irv97_16x16 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -enc "-i ${images_folder}/mm.ppm -o simple_enc_irv97_16x16.j2c -qstep 0.01 -block_size \{16,16\}" "-i simple_enc_irv97_16x16.j2c -o test1.ppm -precise -quiet" "-i simple_enc_irv97_16x16.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### simple_enc_irv97_64x64_16bit_gray CTest command Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Adds a CTest test that encodes 16-bit grayscale mm.pgm with qstep 0.01 and verifies decoding with and without -precise. ```CMake add_test(NAME simple_enc_irv97_64x64_16bit_gray COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -enc "-i ${images_folder}/mm.pgm -o simple_enc_irv97_64x64_16bit_gray.j2c -qstep 0.01" "-i simple_enc_irv97_64x64_16bit_gray.j2c -o test1.pgm -precise -quiet" "-i simple_enc_irv97_64x64_16bit_gray.j2c -o test2.pgm" "${images_folder}/mm.pgm" "test1.pgm" "test2.pgm") ``` -------------------------------- ### Decode test with 64x64 codeblock Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Runs a decoding test using com_decom.sh with a 64x64 codeblock size. Encodes mm.ppm to simple_dec_irv97_64x64.jph, then decodes it twice (with and without -precise) and compares outputs. ```cmake add_test(NAME simple_dec_irv97_64x64 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -dec "-i ${images_folder}/mm.ppm -o simple_dec_irv97_64x64.jph -precise -quiet -rate 0.5 -full" "-i simple_dec_irv97_64x64.jph -o test1.ppm -precise -quiet" "-i simple_dec_irv97_64x64.jph -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Configure test_mixed_coc target Source: https://github.com/aous72/openjph/blob/master/tests/CMakeLists.txt Defines the test_mixed_coc executable from test_mixed_coc.cpp for QCD/QCC marker tests. Links against openjph and GTest::gtest_main. ```cmake add_executable( test_mixed_coc test_mixed_coc.cpp ) target_link_libraries( test_mixed_coc openjph GTest::gtest_main ) ``` -------------------------------- ### Encode with 4x4 block size Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Adds a CTest test named simple_enc_irv97_4x4 that runs com_decom.sh with -enc. It encodes mm.ppm to a .j2c file with qstep 0.01 and block_size {4,4}, decodes it twice (with and without -precise -quiet), and compares outputs against mm.ppm. ```CMake add_test(NAME simple_enc_irv97_4x4 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -enc "-i ${images_folder}/mm.ppm -o simple_enc_irv97_4x4.j2c -qstep 0.01 -block_size \{4,4\}" "-i simple_enc_irv97_4x4.j2c -o test1.ppm -precise -quiet" "-i simple_enc_irv97_4x4.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Encode with 512x8 block size Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Adds a CTest test named simple_enc_irv97_512x8 that runs com_decom.sh with -enc. It encodes mm.ppm to a .j2c file with qstep 0.01 and block_size {8,512}, decodes it twice (with and without -precise -quiet), and compares outputs against mm.ppm. ```CMake add_test(NAME simple_enc_irv97_512x8 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -enc "-i ${images_folder}/mm.ppm -o simple_enc_irv97_512x8.j2c -qstep 0.01 -block_size \{8,512\}" "-i simple_enc_irv97_512x8.j2c -o test1.ppm -precise -quiet" "-i simple_enc_irv97_512x8.j2c -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Windows cmake generation with Visual Studio 17 2022 Source: https://github.com/aous72/openjph/blob/master/docs/compiling.md Generate a Visual Studio solution in the build folder. Requires libtiff; set CMAKE_PREFIX_PATH to the tiff library path. Other Visual Studio versions are supported by cmake. ```bash cd build cmake .. -G "Visual Studio 17 2022 Win64" -DCMAKE_PREFIX_PATH= ``` -------------------------------- ### Compile C++ to WASM with wasi-sdk clang Source: https://github.com/aous72/openjph/blob/master/subprojects/js/standalone/README.md Use the wasi-sdk clang compiler with the wasi-sysroot to compile C++ code to a standalone WASM file. As of this writing, wasi-sdk and wasmer do not support C++ exceptions, so try/throw/catch statements must be removed and 'new' must be changed to 'new (std::nothrow)' with '#include '. WASM exceptions can be enabled with the clang flag '-fwasm-exceptions'. ```bash /home/aous/wasi-sdk-15.0/bin/clang --sysroot=/home/aous/wasi-sdk-15.0/share/wasi-sysroot/ ... ``` -------------------------------- ### Empty ARM Architecture Conditional Block Source: https://github.com/aous72/openjph/blob/master/src/core/CMakeLists.txt Placeholder conditional block for ARM architecture targets (OJPH_ARCH_ARM or MULTI_GEN_ARM64). Currently contains no configuration commands. ```cmake if (("${OJPH_TARGET_ARCH}" MATCHES "OJPH_ARCH_ARM") OR MULTI_GEN_ARM64) endif() ``` -------------------------------- ### Decode test with 32x32 codeblock Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Runs a decoding test using com_decom.sh with a 32x32 codeblock size. Encodes mm.ppm to simple_dec_irv97_32x32.jph, then decodes it twice (with and without -precise) and compares outputs. ```cmake add_test(NAME simple_dec_irv97_32x32 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -dec "-i ${images_folder}/mm.ppm -o simple_dec_irv97_32x32.jph -precise -quiet -rate 1 Cblk=\{32,32\} -full" "-i simple_dec_irv97_32x32.jph -o test1.ppm -precise -quiet" "-i simple_dec_irv97_32x32.jph -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Configure test_nlt target Source: https://github.com/aous72/openjph/blob/master/tests/CMakeLists.txt Defines the test_nlt executable from test_nlt.cpp for NLT (non-linearity point transformation) API tests. Links against openjph and GTest::gtest_main. ```cmake add_executable( test_nlt test_nlt.cpp ) target_link_libraries( test_nlt openjph GTest::gtest_main ) ``` -------------------------------- ### Decode test with 256x16 codeblock Source: https://github.com/aous72/openjph/blob/master/tests/test_helpers/ht_cmdlines.txt Runs a decoding test using com_decom.sh with a 256x16 codeblock size. Encodes mm.ppm to simple_dec_irv97_256x16.jph, then decodes it twice (with and without -precise) and compares outputs. ```cmake add_test(NAME simple_dec_irv97_256x16 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/com_decom.sh -dec "-i ${images_folder}/mm.ppm -o simple_dec_irv97_256x16.jph -precise -quiet -rate 1 Cblk=\{256,16\} -full" "-i simple_dec_irv97_256x16.jph -o test1.ppm -precise -quiet" "-i simple_dec_irv97_256x16.jph -o test2.ppm" "${images_folder}/mm.ppm" "test1.ppm" "test2.ppm") ``` -------------------------------- ### Link Threads::Threads with --no-as-needed on Linux Source: https://github.com/aous72/openjph/blob/master/src/core/CMakeLists.txt Finds the Threads package and links it to the openjph library. On Linux with GNU/Clang, forces linking with --no-as-needed to avoid dropping pthread references. ```cmake find_package(Threads REQUIRED) if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") target_link_libraries(openjph PUBLIC "-Wl,--no-as-needed" Threads::Threads) else() target_link_libraries(openjph PUBLIC Threads::Threads) endif() ```