diff --git a/.editorconfig b/.editorconfig index 1318401..7d0188a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,6 +16,7 @@ file_header_template = Copyright © Clinton Ingram and Contributors. Licensed u csharp_style_prefer_range_operator = true:silent csharp_style_prefer_utf8_string_literals = true:silent csharp_style_deconstructed_variable_declaration = true:silent +csharp_style_namespace_declarations = file_scoped:suggestion dotnet_diagnostic.CA1031.severity = silent dotnet_diagnostic.CA1308.severity = silent diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..a0b53a1 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# switch to file-scoped namespaces +9bd127e20ffe2923033ea5cd09495977bb893a1a diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 603e913..130a094 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,26 +22,29 @@ jobs: linux-arm64: imageName: ubuntu-latest setupScript: | - sudo apt-get update - sudo apt-get install -y g++-aarch64-linux-gnu + sudo apt update + sudo apt install -y g++-aarch64-linux-gnu modules/vcpkg/bootstrap-vcpkg.sh - buildScript: modules/vcpkg/vcpkg install libheif libjxl libwebp --triplet=arm64-linux-staticdependencies @build/vcpkg/response + buildScript: modules/vcpkg/vcpkg install libheif libjxl libwebp psjpeg --triplet=arm64-linux-staticdependencies @build/vcpkg/response linux-x64: imageName: ubuntu-latest - setupScript: modules/vcpkg/bootstrap-vcpkg.sh - buildScript: modules/vcpkg/vcpkg install libheif libjxl libwebp --triplet=x64-linux-staticdependencies @build/vcpkg/response + setupScript: | + sudo apt update + sudo apt install -y nasm + modules/vcpkg/bootstrap-vcpkg.sh + buildScript: modules/vcpkg/vcpkg install libheif libjxl libwebp psjpeg --triplet=x64-linux-staticdependencies @build/vcpkg/response windows-arm64: imageName: windows-latest setupScript: modules\vcpkg\bootstrap-vcpkg.bat - buildScript: modules\vcpkg\vcpkg install libheif libjxl libwebp --triplet=arm64-windows-staticdependencies @build\vcpkg\response + buildScript: modules\vcpkg\vcpkg install libheif libjxl libwebp psjpeg --triplet=arm64-windows-staticdependencies @build\vcpkg\response windows-x64: imageName: windows-latest setupScript: modules\vcpkg\bootstrap-vcpkg.bat - buildScript: modules\vcpkg\vcpkg install libheif libjxl libwebp --triplet=x64-windows-staticdependencies @build\vcpkg\response + buildScript: modules\vcpkg\vcpkg install libheif libjxl libwebp psjpeg --triplet=x64-windows-staticdependencies @build\vcpkg\response windows-x86: imageName: windows-latest setupScript: modules\vcpkg\bootstrap-vcpkg.bat - buildScript: modules\vcpkg\vcpkg install libheif libjxl libwebp --triplet=x86-windows-staticdependencies @build\vcpkg\response + buildScript: modules\vcpkg\vcpkg install libheif libjxl libwebp psjpeg --triplet=x86-windows-staticdependencies @build\vcpkg\response pool: vmImage: $(imageName) diff --git a/build/vcpkg/libraries.cmake b/build/vcpkg/libraries.cmake index 9a6db51..434da1c 100644 --- a/build/vcpkg/libraries.cmake +++ b/build/vcpkg/libraries.cmake @@ -1 +1,3 @@ -set(_PKG_LIBS libheif libjxl libwebp) +set(_PKG_LIBS libheif libjxl libwebp psjpeg) + +set(VCPKG_DISABLE_COMPILER_TRACKING true) diff --git a/build/vcpkg/ports/psjpeg/add-options-for-exes-docs-headers.patch b/build/vcpkg/ports/psjpeg/add-options-for-exes-docs-headers.patch new file mode 100644 index 0000000..a257ad7 --- /dev/null +++ b/build/vcpkg/ports/psjpeg/add-options-for-exes-docs-headers.patch @@ -0,0 +1,176 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 10a198f..68ac5a3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -168,6 +168,12 @@ option(ENABLE_SHARED "Build shared libraries" TRUE) + boolean_number(ENABLE_SHARED) + option(ENABLE_STATIC "Build static libraries" TRUE) + boolean_number(ENABLE_STATIC) ++option(ENABLE_EXECUTABLES "Build executables" TRUE) ++boolean_number(ENABLE_EXECUTABLES) ++option(INSTALL_DOCS "Install doc files" TRUE) ++boolean_number(INSTALL_DOCS) ++option(INSTALL_HEADERS "Install header files" TRUE) ++boolean_number(INSTALL_HEADERS) + option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE) + boolean_number(REQUIRE_SIMD) + option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE) +@@ -634,6 +640,7 @@ if(WITH_TURBOJPEG) + LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}") + endif() + ++ if(ENABLE_EXECUTABLES) + add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c) + target_link_libraries(tjunittest turbojpeg) + +@@ -646,6 +653,7 @@ if(WITH_TURBOJPEG) + add_executable(tjexample tjexample.c) + target_link_libraries(tjexample turbojpeg) + endif() ++ endif() + + if(ENABLE_STATIC) + add_library(turbojpeg-static STATIC ${JPEG_SOURCES} $ +@@ -657,6 +665,7 @@ if(WITH_TURBOJPEG) + set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg) + endif() + ++ if(ENABLE_EXECUTABLES) + add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c + md5/md5hl.c) + target_link_libraries(tjunittest-static turbojpeg-static) +@@ -666,6 +675,7 @@ if(WITH_TURBOJPEG) + if(UNIX) + target_link_libraries(tjbench-static m) + endif() ++ endif() + endif() + endif() + +@@ -680,7 +690,7 @@ else() + set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c) + endif() + +-if(ENABLE_STATIC) ++if(ENABLE_STATIC AND ENABLE_EXECUTABLES) + add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c + ${CJPEG_BMP_SOURCES}) + set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) +@@ -696,10 +706,11 @@ if(ENABLE_STATIC) + set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "${USE_SETMODE}") + endif() + ++if(ENABLE_EXECUTABLES) + add_executable(rdjpgcom rdjpgcom.c) + + add_executable(wrjpgcom wrjpgcom.c) +- ++endif() + + ############################################################################### + # TESTS +@@ -1434,8 +1445,10 @@ if(WITH_TURBOJPEG) + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++ if(ENABLE_EXECUTABLES) + install(TARGETS tjbench + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++ endif() + if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND + CMAKE_C_LINKER_SUPPORTS_PDB) + install(FILES "$" +@@ -1446,7 +1459,7 @@ if(WITH_TURBOJPEG) + install(TARGETS turbojpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- if(NOT ENABLE_SHARED) ++ if(NOT ENABLE_SHARED AND ENABLE_EXECUTABLES) + if(MSVC_IDE OR XCODE) + set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}") + else() +@@ -1456,15 +1469,17 @@ if(WITH_TURBOJPEG) + DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE}) + endif() + endif() ++ if(INSTALL_HEADERS) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ++ endif() + endif() + + if(ENABLE_STATIC) + install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +- if(NOT ENABLE_SHARED) ++ if(NOT ENABLE_SHARED AND ENABLE_EXECUTABLES) + if(MSVC_IDE OR XCODE) + set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}") + else() +@@ -1479,8 +1494,11 @@ if(ENABLE_STATIC) + endif() + endif() + ++if(ENABLE_EXECUTABLES) + install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++endif() + ++if(INSTALL_DOCS) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg + ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt + ${CMAKE_CURRENT_SOURCE_DIR}/tjexample.c +@@ -1492,8 +1510,9 @@ if(WITH_JAVA) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java + DESTINATION ${CMAKE_INSTALL_DOCDIR}) + endif() ++endif() + +-if(UNIX OR MINGW) ++if((UNIX OR MINGW) AND INSTALL_DOCS) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cjpeg.1 + ${CMAKE_CURRENT_SOURCE_DIR}/djpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/jpegtran.1 + ${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1 +@@ -1511,10 +1530,12 @@ install(EXPORT ${CMAKE_PROJECT_NAME}Targets + NAMESPACE ${CMAKE_PROJECT_NAME}:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}) + ++if(INSTALL_HEADERS) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h + ${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h + ${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ++endif() + + include(cmakescripts/BuildPackages.cmake) + +diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt +index 78a2f28..e653b2d 100644 +--- a/sharedlib/CMakeLists.txt ++++ b/sharedlib/CMakeLists.txt +@@ -71,6 +71,7 @@ else() + set(DJPEG_BMP_SOURCES ../wrbmp.c ../wrtarga.c) + endif() + ++if(ENABLE_EXECUTABLES) + add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c + ../rdswitch.c ${CJPEG_BMP_SOURCES}) + set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) +@@ -87,14 +88,17 @@ set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "${USE_SETMODE}") + + add_executable(jcstest ../jcstest.c) + target_link_libraries(jcstest jpeg) ++endif() + + install(TARGETS jpeg EXPORT ${CMAKE_PROJECT_NAME}Targets + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++if(ENABLE_EXECUTABLES) + install(TARGETS cjpeg djpeg jpegtran + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++endif() + if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND + CMAKE_C_LINKER_SUPPORTS_PDB) + install(FILES "$" diff --git a/build/vcpkg/ports/psjpeg/portfile.cmake b/build/vcpkg/ports/psjpeg/portfile.cmake new file mode 100644 index 0000000..fc06ae8 --- /dev/null +++ b/build/vcpkg/ports/psjpeg/portfile.cmake @@ -0,0 +1,100 @@ +if(EXISTS "${CURRENT_INSTALLED_DIR}/share/mozjpeg/copyright") + message(FATAL_ERROR "Can't build ${PORT} if mozjpeg is installed. Please remove mozjpeg:${TARGET_TRIPLET}, and try to install ${PORT}:${TARGET_TRIPLET} again.") +endif() + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO libjpeg-turbo/libjpeg-turbo + REF 2.1.4 + SHA512 d3e92d614168355827e0ed884ff847cc7df8f6f1fb7b673c6c99afdf61fdfc0372afe5d30fdbf5e743335e2a7a27ca9f510c67d213e5cb2315a8d946e9414575 + HEAD_REF master + PATCHES + add-options-for-exes-docs-headers.patch + psjpeg-customize-build.patch + psjpeg-customize-code.patch +) + +file(COPY ${CURRENT_PORT_DIR}/psjpeg.c DESTINATION ${SOURCE_PATH}) +file(COPY ${CURRENT_PORT_DIR}/psjpeg.h DESTINATION ${SOURCE_PATH}) + +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" OR (VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")) + set(LIBJPEGTURBO_SIMD -DWITH_SIMD=ON -DNEON_INTRINSICS=ON) +else() + set(LIBJPEGTURBO_SIMD -DWITH_SIMD=ON) + vcpkg_find_acquire_program(NASM) + get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) + set(ENV{PATH} "$ENV{PATH};${NASM_EXE_PATH}") +endif() + +if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + set(ENV{_CL_} "-DNO_GETENV -DNO_PUTENV") +endif() + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ENABLE_SHARED) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" WITH_CRT_DLL) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + jpeg7 WITH_JPEG7 + jpeg8 WITH_JPEG8 +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DENABLE_STATIC=${ENABLE_STATIC} + -DENABLE_SHARED=${ENABLE_SHARED} + -DREQUIRE_SIMD=ON + -DWITH_MEM_SRCDST=OFF + -DWITH_TURBOJPEG=OFF + -DENABLE_EXECUTABLES=OFF + -DINSTALL_DOCS=OFF + -DWITH_CRT_DLL=${WITH_CRT_DLL} + ${FEATURE_OPTIONS} + ${LIBJPEGTURBO_SIMD} + OPTIONS_DEBUG + -DINSTALL_HEADERS=OFF + MAYBE_UNUSED_VARIABLES + WITH_CRT_DLL +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +vcpkg_fixup_pkgconfig() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libjpeg-turbo) + +# Rename libraries for static builds +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/jpeg-static.lib") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/jpeg-static.lib" "${CURRENT_PACKAGES_DIR}/lib/jpeg.lib") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/turbojpeg-static.lib" "${CURRENT_PACKAGES_DIR}/lib/turbojpeg.lib") + endif() + if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg-static.lib") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg.lib") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg.lib") + endif() + + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") + + if (EXISTS "${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-debug.cmake") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-debug.cmake" + "jpeg-static${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "jpeg${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-debug.cmake" + "turbojpeg-static${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "turbojpeg${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}") + endif() + if (EXISTS "${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-release.cmake") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-release.cmake" + "jpeg-static${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "jpeg${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/libjpeg-turboTargets-release.cmake" + "turbojpeg-static${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}" "turbojpeg${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX}") + endif() +endif() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/share/man") + +file(INSTALL "${SOURCE_PATH}/LICENSE.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/build/vcpkg/ports/psjpeg/psjpeg-customize-build.patch b/build/vcpkg/ports/psjpeg/psjpeg-customize-build.patch new file mode 100644 index 0000000..49d315a --- /dev/null +++ b/build/vcpkg/ports/psjpeg/psjpeg-customize-build.patch @@ -0,0 +1,43 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index cf2fa1e..c298606 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -588,7 +588,7 @@ if(WITH_JAVA) + add_subdirectory(java) + endif() + +-if(ENABLE_SHARED) ++if(ENABLE_SHARED AND WITH_TURBOJPEG) + add_subdirectory(sharedlib) + endif() + +@@ -679,6 +679,11 @@ if(WITH_TURBOJPEG) + endif() + endif() + ++set(PSJPEG_SOURCES ${JPEG_SOURCES} $ ${SIMD_OBJS} psjpeg.c) ++set(CMAKE_C_VISIBILITY_PRESET hidden) ++add_library(psjpeg SHARED ${PSJPEG_SOURCES}) ++set_target_properties(psjpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE) ++ + if(WIN32) + set(USE_SETMODE "-DUSE_SETMODE") + endif() +@@ -1475,6 +1480,17 @@ if(WITH_TURBOJPEG) + endif() + endif() + ++install(TARGETS psjpeg EXPORT ${CMAKE_PROJECT_NAME}Targets ++ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ++if(MSVC AND CMAKE_C_LINKER_SUPPORTS_PDB) ++ install(FILES "$" ++ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) ++endif() ++install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/psjpeg.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ++ + if(ENABLE_STATIC) + install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} diff --git a/build/vcpkg/ports/psjpeg/psjpeg-customize-code.patch b/build/vcpkg/ports/psjpeg/psjpeg-customize-code.patch new file mode 100644 index 0000000..6b6b8b3 --- /dev/null +++ b/build/vcpkg/ports/psjpeg/psjpeg-customize-code.patch @@ -0,0 +1,217 @@ +diff --git a/jddctmgr.c b/jddctmgr.c +index e78d7be..38532a6 100644 +--- a/jddctmgr.c ++++ b/jddctmgr.c +@@ -119,10 +119,14 @@ start_pass(j_decompress_ptr cinfo) + method_ptr = jpeg_idct_2x2; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; ++#endif ++#ifdef IDCT_SCALING_SUPPORTED_ODD + case 3: + method_ptr = jpeg_idct_3x3; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ + break; ++#endif ++#ifdef IDCT_SCALING_SUPPORTED + case 4: + if (jsimd_can_idct_4x4()) + method_ptr = jsimd_idct_4x4; +@@ -130,6 +134,8 @@ start_pass(j_decompress_ptr cinfo) + method_ptr = jpeg_idct_4x4; + method = JDCT_ISLOW; /* jidctred uses islow-style table */ + break; ++#endif ++#ifdef IDCT_SCALING_SUPPORTED_ODD + case 5: + method_ptr = jpeg_idct_5x5; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ +@@ -182,7 +188,7 @@ start_pass(j_decompress_ptr cinfo) + break; + } + break; +-#ifdef IDCT_SCALING_SUPPORTED ++#ifdef IDCT_SCALING_SUPPORTED_ODD + case 9: + method_ptr = jpeg_idct_9x9; + method = JDCT_ISLOW; /* jidctint uses islow-style table */ +diff --git a/jdmaster.c b/jdmaster.c +index a3690bf..dfa600d 100644 +--- a/jdmaster.c ++++ b/jdmaster.c +@@ -114,6 +114,7 @@ jpeg_core_output_dimensions(j_decompress_ptr cinfo) + jdiv_round_up((long)cinfo->image_height * 2L, (long)DCTSIZE); + cinfo->_min_DCT_h_scaled_size = 2; + cinfo->_min_DCT_v_scaled_size = 2; ++#ifdef IDCT_SCALING_SUPPORTED_ODD + } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 3) { + /* Provide 3/block_size scaling */ + cinfo->output_width = (JDIMENSION) +@@ -122,6 +123,7 @@ jpeg_core_output_dimensions(j_decompress_ptr cinfo) + jdiv_round_up((long)cinfo->image_height * 3L, (long)DCTSIZE); + cinfo->_min_DCT_h_scaled_size = 3; + cinfo->_min_DCT_v_scaled_size = 3; ++#endif + } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 4) { + /* Provide 4/block_size scaling */ + cinfo->output_width = (JDIMENSION) +@@ -130,6 +132,7 @@ jpeg_core_output_dimensions(j_decompress_ptr cinfo) + jdiv_round_up((long)cinfo->image_height * 4L, (long)DCTSIZE); + cinfo->_min_DCT_h_scaled_size = 4; + cinfo->_min_DCT_v_scaled_size = 4; ++#ifdef IDCT_SCALING_SUPPORTED_ODD + } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 5) { + /* Provide 5/block_size scaling */ + cinfo->output_width = (JDIMENSION) +@@ -155,6 +158,9 @@ jpeg_core_output_dimensions(j_decompress_ptr cinfo) + cinfo->_min_DCT_h_scaled_size = 7; + cinfo->_min_DCT_v_scaled_size = 7; + } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 8) { ++#else ++ } else { ++#endif + /* Provide 8/block_size scaling */ + cinfo->output_width = (JDIMENSION) + jdiv_round_up((long)cinfo->image_width * 8L, (long)DCTSIZE); +@@ -162,6 +168,7 @@ jpeg_core_output_dimensions(j_decompress_ptr cinfo) + jdiv_round_up((long)cinfo->image_height * 8L, (long)DCTSIZE); + cinfo->_min_DCT_h_scaled_size = 8; + cinfo->_min_DCT_v_scaled_size = 8; ++#ifdef IDCT_SCALING_SUPPORTED_ODD + } else if (cinfo->scale_num * DCTSIZE <= cinfo->scale_denom * 9) { + /* Provide 9/block_size scaling */ + cinfo->output_width = (JDIMENSION) +@@ -226,6 +233,7 @@ jpeg_core_output_dimensions(j_decompress_ptr cinfo) + jdiv_round_up((long)cinfo->image_height * 16L, (long)DCTSIZE); + cinfo->_min_DCT_h_scaled_size = 16; + cinfo->_min_DCT_v_scaled_size = 16; ++#endif + } + + /* Recompute dimensions of components */ +diff --git a/jdmerge.c b/jdmerge.c +index 3a456d6..34a4c5b 100644 +--- a/jdmerge.c ++++ b/jdmerge.c +@@ -585,4 +585,12 @@ jinit_merged_upsampler(j_decompress_ptr cinfo) + build_ycc_rgb_table(cinfo); + } + ++#else ++ ++GLOBAL(void) ++jinit_merged_upsampler(j_decompress_ptr cinfo) ++{ ++ ERREXIT(cinfo, JERR_NOT_COMPILED); ++} ++ + #endif /* UPSAMPLE_MERGING_SUPPORTED */ +diff --git a/jidctint.c b/jidctint.c +index bb08748..10ff856 100644 +--- a/jidctint.c ++++ b/jidctint.c +@@ -412,7 +412,7 @@ jpeg_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr, + } + } + +-#ifdef IDCT_SCALING_SUPPORTED ++#ifdef IDCT_SCALING_SUPPORTED_ODD + + + /* +diff --git a/jmorecfg.h b/jmorecfg.h +index b33a991..2b94a36 100644 +--- a/jmorecfg.h ++++ b/jmorecfg.h +@@ -24,7 +24,7 @@ + * bytes of storage, whether actually used in an image or not.) + */ + +-#define MAX_COMPONENTS 10 /* maximum number of image components */ ++#define MAX_COMPONENTS 4 /* maximum number of image components */ + + + /* +@@ -251,19 +251,19 @@ typedef int boolean; + * The exact same statements apply for progressive JPEG: the default tables + * don't work for progressive mode. (This may get fixed, however.) + */ +-#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ ++//#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ + + /* Decoder capability options: */ + + #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ + #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ + #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ +-#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ ++//#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ + #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ + #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ +-#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ +-#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ +-#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ ++//#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ ++//#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ ++//#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ + + /* more capability options later, no doubt */ + +diff --git a/jquant1.c b/jquant1.c +index 73b83e1..d280caa 100644 +--- a/jquant1.c ++++ b/jquant1.c +@@ -853,4 +853,12 @@ jinit_1pass_quantizer(j_decompress_ptr cinfo) + alloc_fs_workspace(cinfo); + } + ++#else ++ ++GLOBAL(void) ++jinit_1pass_quantizer(j_decompress_ptr cinfo) ++{ ++ ERREXIT(cinfo, JERR_NOT_COMPILED); ++} ++ + #endif /* QUANT_1PASS_SUPPORTED */ +diff --git a/jquant2.c b/jquant2.c +index 44efb18..33a2b62 100644 +--- a/jquant2.c ++++ b/jquant2.c +@@ -1282,4 +1282,12 @@ jinit_2pass_quantizer(j_decompress_ptr cinfo) + } + } + ++#else ++ ++GLOBAL(void) ++jinit_2pass_quantizer(j_decompress_ptr cinfo) ++{ ++ ERREXIT(cinfo, JERR_NOT_COMPILED); ++} ++ + #endif /* QUANT_2PASS_SUPPORTED */ +diff --git a/win/jconfig.h.in b/win/jconfig.h.in +index 0fca77b..0d623fb 100644 +--- a/win/jconfig.h.in ++++ b/win/jconfig.h.in +@@ -6,17 +6,13 @@ + #cmakedefine D_ARITH_CODING_SUPPORTED + #cmakedefine MEM_SRCDST_SUPPORTED + #cmakedefine WITH_SIMD ++#define NO_GETENV ++#define NO_PUTENV + + #define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */ + + #undef RIGHT_SHIFT_IS_UNSIGNED + +-/* Define "boolean" as unsigned char, not int, per Windows custom */ +-#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ +-typedef unsigned char boolean; +-#endif +-#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +- + /* Define "INT32" as int, not long, per Windows custom */ + #if !(defined(_BASETSD_H_) || defined(_BASETSD_H)) /* don't conflict if basetsd.h already read */ + typedef short INT16; diff --git a/build/vcpkg/ports/psjpeg/psjpeg.c b/build/vcpkg/ports/psjpeg/psjpeg.c new file mode 100644 index 0000000..a36da57 --- /dev/null +++ b/build/vcpkg/ports/psjpeg/psjpeg.c @@ -0,0 +1,337 @@ +// Copyright © Clinton Ingram and Contributors. Licensed under the MIT License. + +#include +#include +#include "jerror.h" +#include "psjpeg.h" + +#if defined(__GNUC__) && defined(__x86_64__) +#include +#elif defined(_MSC_VER) +#include +#else +#include +#define _mm_free(p) free(p) +#define _mm_malloc(a, b) malloc(a) +#endif + +#ifdef sigsetjmp +#define SETJMP(e) sigsetjmp((e), 0) +#define LONGJMP siglongjmp +#else +#define SETJMP setjmp +#define LONGJMP longjmp +#endif + +#define TRY int _jmp_res; if (!(_jmp_res = SETJMP(((ps_error_mgr*)cinfo->err)->jmp_buf))) +#define CATCH else +#define TRY_RESULT !_jmp_res ? TRUE : FALSE; + +// attempt to pad ps_err_mgr so that jmp_buf is 16-byte aligned +#if defined(__GNUC__) && (defined(__x86_64__) || defined(__aarch64__)) +#define JMSG_PAD 4 +#else +#define JMSG_PAD sizeof(size_t) +#endif + +#define SRC_BUF_SIZE 4096 +#define DST_BUF_SIZE 4096 +#define MSG_BUF_SIZE JMSG_LENGTH_MAX + JMSG_PAD + +typedef struct { + struct jpeg_error_mgr pub; + char msg[MSG_BUF_SIZE]; + jmp_buf jmp_buf; +} ps_error_mgr; + +typedef struct { + struct jpeg_destination_mgr pub; + JOCTET* buff; +} ps_dest_mgr; + +typedef struct { + struct jpeg_source_mgr pub; + JOCTET* buff; +} ps_src_mgr; + +static void nullEmit(j_common_ptr cinfo, int msg_level) { } +static void nullOutput(j_common_ptr cinfo) { } +static void nullSource(j_decompress_ptr cinfo) { } + +static void throwError(j_common_ptr cinfo) { + ps_error_mgr* err = (ps_error_mgr*)cinfo->err; + (*cinfo->err->format_message)(cinfo, err->msg); + + LONGJMP(err->jmp_buf, err->pub.msg_code); +} + +static void initDest(j_compress_ptr cinfo) { + ps_dest_mgr* dest = (ps_dest_mgr*)cinfo->dest; + + dest->buff = (JOCTET*)(*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, DST_BUF_SIZE * sizeof(JOCTET)); + dest->pub.next_output_byte = dest->buff; + dest->pub.free_in_buffer = DST_BUF_SIZE; +} + +static boolean writeDest(j_compress_ptr cinfo) { + ps_client_data* client = (ps_client_data*)cinfo->client_data; + ps_dest_mgr* dest = (ps_dest_mgr*)cinfo->dest; + + if ((*client->write_file)(client->stream_handle, dest->buff, DST_BUF_SIZE) != DST_BUF_SIZE) + ERREXIT(cinfo, JERR_FILE_WRITE); + + dest->pub.next_output_byte = dest->buff; + dest->pub.free_in_buffer = DST_BUF_SIZE; + + return TRUE; +} + +static void termDest(j_compress_ptr cinfo) { + ps_client_data* client = (ps_client_data*)cinfo->client_data; + ps_dest_mgr* dest = (ps_dest_mgr*)cinfo->dest; + size_t cb = DST_BUF_SIZE - dest->pub.free_in_buffer; + + if (cb > 0 && (*client->write_file)(client->stream_handle, dest->buff, cb) != cb) + ERREXIT(cinfo, JERR_FILE_WRITE); +} + +static boolean fillSource(j_decompress_ptr cinfo) +{ + ps_client_data* client = (ps_client_data*)cinfo->client_data; + ps_src_mgr* src = (ps_src_mgr*)cinfo->src; + + size_t cb = (*client->read_file)(client->stream_handle, src->buff, SRC_BUF_SIZE); + if (cb == ~0) + ERREXIT(cinfo, JERR_FILE_READ); + + src->pub.next_input_byte = src->buff; + src->pub.bytes_in_buffer = cb; + + return TRUE; +} + +static void skipSource(j_decompress_ptr cinfo, long num_bytes) +{ + ps_client_data* client = (ps_client_data*)cinfo->client_data; + ps_src_mgr* src = (ps_src_mgr*)cinfo->src; + size_t cb = (size_t)num_bytes; + + if (cb > src->pub.bytes_in_buffer) { + cb -= src->pub.bytes_in_buffer; + cb = (*client->seek_file)(client->stream_handle, cb); + if (cb == ~0) + ERREXIT(cinfo, JERR_FILE_READ); + + if (cb == 0) { + // EOF reached -- fabricate an EOI marker + src->buff[0] = (JOCTET)0xFF; + src->buff[1] = (JOCTET)JPEG_EOI; + cb = 2; + } + + src->pub.next_input_byte = NULL; + src->pub.bytes_in_buffer = 0; + } else { + src->pub.next_input_byte += cb; + src->pub.bytes_in_buffer -= cb; + } +} + +static struct jpeg_error_mgr* setErr(ps_error_mgr* err) { + struct jpeg_error_mgr* jerr = (struct jpeg_error_mgr*)err; + + jpeg_std_error(jerr); + jerr->error_exit = throwError; + jerr->output_message = nullOutput; + jerr->emit_message = nullEmit; + memset(&err->msg, 0, MSG_BUF_SIZE); + + return jerr; +} + +static void setDest(j_compress_ptr cinfo) { + ps_dest_mgr* dest = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_PERMANENT, sizeof(ps_dest_mgr)); + + dest->buff = NULL; + dest->pub.init_destination = initDest; + dest->pub.empty_output_buffer = writeDest; + dest->pub.term_destination = termDest; + + cinfo->dest = (struct jpeg_destination_mgr*)dest; +} + +static void setSource(j_decompress_ptr cinfo) { + ps_src_mgr* src = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_PERMANENT, sizeof(ps_src_mgr)); + + src->buff = (JOCTET*)(*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_PERMANENT, SRC_BUF_SIZE * sizeof(JOCTET)); + src->pub.init_source = nullSource; + src->pub.fill_input_buffer = fillSource; + src->pub.skip_input_data = skipSource; + src->pub.resync_to_restart = jpeg_resync_to_restart; + src->pub.term_source = nullSource; + src->pub.next_input_byte = NULL; + src->pub.bytes_in_buffer = 0; + + cinfo->src = (struct jpeg_source_mgr*)src; +} + +j_compress_ptr JpegCreateCompress() { + j_compress_ptr cinfo = (j_compress_ptr)malloc(sizeof(struct jpeg_compress_struct)); + ps_error_mgr* err = (ps_error_mgr*)_mm_malloc(sizeof(ps_error_mgr), 16); + if (!cinfo || !err) { + _mm_free(err); + free(cinfo); + return NULL; + } + + cinfo->err = setErr(err); + + TRY { + jpeg_create_compress(cinfo); + setDest(cinfo); + return cinfo; + } CATCH { + JpegDestroy((j_common_ptr)cinfo); + return NULL; + } +} + +j_decompress_ptr JpegCreateDecompress() { + j_decompress_ptr cinfo = (j_decompress_ptr)malloc(sizeof(struct jpeg_decompress_struct)); + ps_error_mgr* err = (ps_error_mgr*)_mm_malloc(sizeof(ps_error_mgr), 16); + if (!cinfo || !err) { + _mm_free(err); + free(cinfo); + return NULL; + } + + cinfo->err = setErr(err); + + TRY{ + jpeg_create_decompress(cinfo); + setSource(cinfo); + return cinfo; + } CATCH { + JpegDestroy((j_common_ptr)cinfo); + return NULL; + } +} + +void JpegDestroy(j_common_ptr cinfo) { + jpeg_destroy(cinfo); + _mm_free(cinfo->err); + free(cinfo); +} + +void JpegAbortDecompress(j_decompress_ptr cinfo) { + jpeg_abort_decompress(cinfo); +} + +const char* JpegGetLastError(j_common_ptr cinfo) { + return ((ps_error_mgr*)cinfo->err)->msg; +} + +int JpegSetDefaults(j_compress_ptr cinfo) { + TRY jpeg_set_defaults(cinfo); + return TRY_RESULT; +} + +int JpegSetQuality(j_compress_ptr cinfo, int quality) { + TRY jpeg_set_quality(cinfo, quality, TRUE); + return TRY_RESULT; +} + +int JpegSimpleProgression(j_compress_ptr cinfo) { + TRY jpeg_simple_progression(cinfo); + return TRY_RESULT; +} + +int JpegStartCompress(j_compress_ptr cinfo) { + TRY jpeg_start_compress(cinfo, TRUE); + return TRY_RESULT; +} + +int JpegWriteScanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines, JDIMENSION* lines_written) { + TRY + *lines_written = jpeg_write_scanlines(cinfo, scanlines, num_lines); + CATCH + *lines_written = 0; + return TRY_RESULT; +} + +int JpegWriteRawData(j_compress_ptr cinfo, JSAMPIMAGE data, JDIMENSION num_lines, JDIMENSION* lines_written) { + TRY + *lines_written = jpeg_write_raw_data(cinfo, data, num_lines); + CATCH + *lines_written = 0; + return TRY_RESULT; +} + +int JpegFinishCompress(j_compress_ptr cinfo) { + TRY jpeg_finish_compress(cinfo); + return TRY_RESULT; +} + +int JpegWriteMarker(j_compress_ptr cinfo, int marker, const JOCTET* dataptr, unsigned int datalen) { + TRY jpeg_write_marker(cinfo, marker, dataptr, datalen); + return TRY_RESULT; +} + +int JpegWriteIccProfile(j_compress_ptr cinfo, const JOCTET* icc_data_ptr, unsigned int icc_data_len) { + TRY jpeg_write_icc_profile(cinfo, icc_data_ptr, icc_data_len); + return TRY_RESULT; +} + +int JpegReadHeader(j_decompress_ptr cinfo) { + TRY jpeg_read_header(cinfo, TRUE); + return TRY_RESULT; +} + +int JpegStartDecompress(j_decompress_ptr cinfo) { + TRY jpeg_start_decompress(cinfo); + return TRY_RESULT; +} + +int JpegReadScanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines, JDIMENSION* lines_read) { + TRY + *lines_read = jpeg_read_scanlines(cinfo, scanlines, max_lines); + CATCH + *lines_read = 0; + return TRY_RESULT; +} + +int JpegReadRawData(j_decompress_ptr cinfo, JSAMPIMAGE data, JDIMENSION max_lines, JDIMENSION* lines_read) { + TRY + *lines_read = jpeg_read_raw_data(cinfo, data, max_lines); + CATCH + *lines_read = 0; + return TRY_RESULT; +} + +int JpegSkipScanlines(j_decompress_ptr cinfo, JDIMENSION num_lines, JDIMENSION* lines_skipped) { + TRY + *lines_skipped = jpeg_skip_scanlines(cinfo, num_lines); + CATCH + *lines_skipped = 0; + return TRY_RESULT; +} + +int JpegCropScanline(j_decompress_ptr cinfo, JDIMENSION* xoffset, JDIMENSION* width) { + TRY jpeg_crop_scanline(cinfo, xoffset, width); + return TRY_RESULT; +} + +int JpegFinishDecompress(j_decompress_ptr cinfo) { + TRY jpeg_finish_decompress(cinfo); + return TRY_RESULT; +} + +int JpegSaveMarkers(j_decompress_ptr cinfo, int marker_code, unsigned int length_limit) { + TRY jpeg_save_markers(cinfo, marker_code, length_limit); + return TRY_RESULT; +} + +int JpegReadIccProfile(j_decompress_ptr cinfo, JOCTET** icc_data_ptr, unsigned int* icc_data_len) { + TRY jpeg_read_icc_profile(cinfo, icc_data_ptr, icc_data_len); + return TRY_RESULT; +} diff --git a/build/vcpkg/ports/psjpeg/psjpeg.h b/build/vcpkg/ports/psjpeg/psjpeg.h new file mode 100644 index 0000000..19be4f5 --- /dev/null +++ b/build/vcpkg/ports/psjpeg/psjpeg.h @@ -0,0 +1,63 @@ +// Copyright © Clinton Ingram and Contributors. Licensed under the MIT License. + +#pragma once + +#include +#include "jpeglib.h" + +typedef struct { + void* stream_handle; + size_t(*write_file)(void* pinst, JOCTET* buff, size_t cb); + size_t(*read_file)(void* pinst, JOCTET* buff, size_t cb); + size_t(*seek_file)(void* pinst, size_t cb); +} ps_client_data; + +#if defined(__GNUC__) && defined(DLLDEFINE) +#define DLLEXPORT __attribute__((__visibility__("default"))) +#elif defined(_MSC_VER) && defined(DLLDEFINE) +#define DLLEXPORT __declspec(dllexport) +#elif defined(_MSC_VER) +#define DLLEXPORT __declspec(dllimport) +#else +#define DLLEXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +DLLEXPORT j_compress_ptr JpegCreateCompress(); +DLLEXPORT j_decompress_ptr JpegCreateDecompress(); + +DLLEXPORT void JpegDestroy(j_common_ptr cinfo); +DLLEXPORT void JpegAbortDecompress(j_decompress_ptr cinfo); + +DLLEXPORT const char* JpegGetLastError(j_common_ptr cinfo); + +DLLEXPORT int JpegSetDefaults(j_compress_ptr cinfo); +DLLEXPORT int JpegSetQuality(j_compress_ptr cinfo, int quality); +DLLEXPORT int JpegSimpleProgression(j_compress_ptr cinfo); + +DLLEXPORT int JpegStartCompress(j_compress_ptr cinfo); +DLLEXPORT int JpegWriteScanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines, JDIMENSION* lines_written); +DLLEXPORT int JpegWriteRawData(j_compress_ptr cinfo, JSAMPIMAGE data, JDIMENSION num_lines, JDIMENSION* lines_written); +DLLEXPORT int JpegFinishCompress(j_compress_ptr cinfo); + +DLLEXPORT int JpegWriteMarker(j_compress_ptr cinfo, int marker, const JOCTET* dataptr, unsigned int datalen); +DLLEXPORT int JpegWriteIccProfile(j_compress_ptr cinfo, const JOCTET* icc_data_ptr, unsigned int icc_data_len); + +DLLEXPORT int JpegReadHeader(j_decompress_ptr cinfo); + +DLLEXPORT int JpegStartDecompress(j_decompress_ptr cinfo); +DLLEXPORT int JpegReadScanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines, JDIMENSION* lines_read); +DLLEXPORT int JpegReadRawData(j_decompress_ptr cinfo, JSAMPIMAGE data, JDIMENSION max_lines, JDIMENSION* lines_read); +DLLEXPORT int JpegSkipScanlines(j_decompress_ptr cinfo, JDIMENSION num_lines, JDIMENSION* lines_skipped); +DLLEXPORT int JpegCropScanline(j_decompress_ptr cinfo, JDIMENSION* xoffset, JDIMENSION* width); +DLLEXPORT int JpegFinishDecompress(j_decompress_ptr cinfo); + +DLLEXPORT int JpegSaveMarkers(j_decompress_ptr cinfo, int marker_code, unsigned int length_limit); +DLLEXPORT int JpegReadIccProfile(j_decompress_ptr cinfo, JOCTET** icc_data_ptr, unsigned int* icc_data_len); + +#ifdef __cplusplus +} +#endif diff --git a/build/vcpkg/ports/psjpeg/vcpkg.json b/build/vcpkg/ports/psjpeg/vcpkg.json new file mode 100644 index 0000000..afa9432 --- /dev/null +++ b/build/vcpkg/ports/psjpeg/vcpkg.json @@ -0,0 +1,25 @@ +{ + "name": "psjpeg", + "version": "2.1.4", + "description": "libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, NEON, AltiVec) to accelerate baseline JPEG compression and decompression on x86, x86-64, ARM, and PowerPC systems.", + "homepage": "https://github.com/libjpeg-turbo/libjpeg-turbo", + "license": "BSD-3-Clause", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "jpeg7": { + "description": "Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward-incompatible with libjpeg v6b!)" + }, + "jpeg8": { + "description": "Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward-incompatible with libjpeg v6b!)" + } + } +} diff --git a/modules/vcpkg b/modules/vcpkg index ed6dc3a..7e1a014 160000 --- a/modules/vcpkg +++ b/modules/vcpkg @@ -1 +1 @@ -Subproject commit ed6dc3a43f976099525c5dcde2bfe7dc4092fb3d +Subproject commit 7e1a0143ab1429c49336a94e33d9e2d9e5959338 diff --git a/src/NativeCodecs/Libheif/readme.md b/src/NativeCodecs/Libheif/readme.md index b7877e5..7018bc2 100644 --- a/src/NativeCodecs/Libheif/readme.md +++ b/src/NativeCodecs/Libheif/readme.md @@ -7,7 +7,7 @@ Be aware that the HEVC video coding standard used in HEIC images is burdened by *By using this plugin, you acknowledge that your use of the codec is permitted royalty free or that you have purchased an appropriate license.* -Windows 10 and 11 include a HEIF codec by default, but it may not function for HEIC images without purchase of an HEVC extension from the Microsoft Store, and it may not function for all users or apps. You may need to unregister the Windows HEIF codec in order to use this plugin for decode. +Windows 10 and 11 include a HEIF codec by default, but it may not function for HEIC images without purchase of an HEVC extension from the Microsoft Store, and it may not function for all users or apps. This plugin is meant to be used when the Windows codec is not available or does not work. Requirements ------------ diff --git a/src/NativeCodecs/Libwebp/External/Interop/encode/Libwebp.cs b/src/NativeCodecs/Libwebp/External/Interop/encode/Libwebp.cs index a2c9d39..2688366 100644 --- a/src/NativeCodecs/Libwebp/External/Interop/encode/Libwebp.cs +++ b/src/NativeCodecs/Libwebp/External/Interop/encode/Libwebp.cs @@ -107,7 +107,7 @@ public static int WebPPictureInit(WebPPicture* picture) public static extern int WebPPictureIsView([NativeTypeName("const WebPPicture *")] WebPPicture* picture); [DllImport("webp", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern int WebPPictureRescale(WebPPicture* pic, int width, int height); + public static extern int WebPPictureRescale(WebPPicture* picture, int width, int height); [DllImport("webp", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int WebPPictureImportRGB(WebPPicture* picture, [NativeTypeName("const uint8_t *")] byte* rgb, int rgb_stride); @@ -149,7 +149,7 @@ public static int WebPPictureInit(WebPPicture* picture) public static extern int WebPPictureHasTransparency([NativeTypeName("const WebPPicture *")] WebPPicture* picture); [DllImport("webp", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void WebPBlendAlpha(WebPPicture* pic, [NativeTypeName("uint32_t")] uint background_rgb); + public static extern void WebPBlendAlpha(WebPPicture* picture, [NativeTypeName("uint32_t")] uint background_rgb); [DllImport("webp", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int WebPEncode([NativeTypeName("const WebPConfig *")] WebPConfig* config, WebPPicture* picture); diff --git a/src/NativeCodecs/Libwebp/NativeCodecs.Libwebp.csproj b/src/NativeCodecs/Libwebp/NativeCodecs.Libwebp.csproj index f06de32..246abab 100644 --- a/src/NativeCodecs/Libwebp/NativeCodecs.Libwebp.csproj +++ b/src/NativeCodecs/Libwebp/NativeCodecs.Libwebp.csproj @@ -1,7 +1,7 @@ - 1.2.2 + 1.2.4 net6.0;net472 $(TargetFrameworks);net461;netstandard2.0 diff --git a/src/NativeCodecs/Libwebp/WebpCodec.cs b/src/NativeCodecs/Libwebp/WebpCodec.cs index d346704..184e2a0 100644 --- a/src/NativeCodecs/Libwebp/WebpCodec.cs +++ b/src/NativeCodecs/Libwebp/WebpCodec.cs @@ -18,9 +18,9 @@ namespace PhotoSauce.NativeCodecs.Libwebp; internal static unsafe class WebpFactory { - public const string DisplayName = $"{libwebp} 1.2.2"; + public const string DisplayName = $"{libwebp} 1.2.4"; public const string libwebp = nameof(libwebp); - public const uint libver = 0x00010202; + public const uint libver = 0x00010204; private static readonly Lazy dependencyValid = new(() => { #if NETFRAMEWORK diff --git a/src/NativeCodecs/Libwebp/readme.md b/src/NativeCodecs/Libwebp/readme.md index c78c23a..3fb5149 100644 --- a/src/NativeCodecs/Libwebp/readme.md +++ b/src/NativeCodecs/Libwebp/readme.md @@ -3,6 +3,8 @@ PhotoSauce.NativeCodecs.Libwebp This MagicScaler plugin wraps the [libwebp](https://chromium.googlesource.com/webm/libwebp) reference [WebP](https://developers.google.com/speed/webp) codec. +Windows 10 and 11 include a WebP decoder by default, but it may not function for all users or apps. This plugin is more capable than the Windows codec and will work anywhere `libwebp` is available. + Requirements ------------ diff --git a/third-party-notices b/third-party-notices index 9c3d93d..51d9d79 100644 --- a/third-party-notices +++ b/third-party-notices @@ -64,4 +64,14 @@ Copyright (c) 2010, Google Inc. All rights reserved. Licensed under a 3-clause BSD License. Available at -https://chromium.googlesource.com/webm/libwebp/+/refs/heads/main/COPYING \ No newline at end of file +https://chromium.googlesource.com/webm/libwebp/+/refs/heads/main/COPYING + +License notice for libjpeg-turbo +-------------------------------- + +Copyright (C)2009-2022 D. R. Commander. All Rights Reserved. +This software is based in part on the work of the Independent JPEG Group. +Licensed under a 3-clause BSD License. + +Available at +https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/LICENSE.md