diff --git a/.gitattributes b/.gitattributes index 9b03811..d9861d7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,3 +21,5 @@ *.xz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text +## Specific LFS patterns +skcms.tar filter=lfs diff=lfs merge=lfs -text diff --git a/0001-Remove-LCMS-mutex.patch b/0001-Remove-LCMS-mutex.patch deleted file mode 100644 index 3657b96..0000000 --- a/0001-Remove-LCMS-mutex.patch +++ /dev/null @@ -1,117 +0,0 @@ -From 057cd06c19875bcf8b5d34d41d92a8abdb856b7c Mon Sep 17 00:00:00 2001 -From: Kleis Auke Wolthuizen -Date: Fri, 11 Mar 2022 21:11:24 +0100 -Subject: [PATCH] Remove LCMS mutex (#112) - -* Remove LCMS mutex - -Requires mm2/Little-CMS@a35bacd, which is released in LCMS v2.11. - -* Use a threadsafe alternative of gmtime in LCMS - -Requires mm2/Little-CMS@68ee2ff, which is released in LCMS v2.13. - -LCMS submodule was updated to version 2.13.1 instead. ---- - lib/jxl/enc_color_management.cc | 15 +++++++++++++++ - third_party/CMakeLists.txt | 2 +- - third_party/lcms2.cmake | 14 -------------- - 3 files changed, 16 insertions(+), 15 deletions(-) - -Index: libjxl-0.8.1/lib/jxl/enc_color_management.cc -=================================================================== ---- libjxl-0.8.1.orig/lib/jxl/enc_color_management.cc -+++ libjxl-0.8.1/lib/jxl/enc_color_management.cc -@@ -18,6 +18,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -308,6 +309,14 @@ int DoColorSpaceTransform(void* t, size_ - // Define to 1 on OS X as a workaround for older LCMS lacking MD5. - #define JXL_CMS_OLD_VERSION 0 - -+// cms functions (even *THR) are not thread-safe, except cmsDoTransform. -+// To ensure all functions are covered without frequent lock-taking nor risk of -+// recursive lock, we lock in the top-level APIs. -+static std::mutex& LcmsMutex() { -+ static std::mutex m; -+ return m; -+} -+ - #if JPEGXL_ENABLE_SKCMS - - JXL_MUST_USE_RESULT CIExy CIExyFromXYZ(const float XYZ[3]) { -@@ -871,6 +880,9 @@ bool ApplyCICP(const uint8_t color_prima - - } // namespace - -+// All functions that call lcms directly (except ColorSpaceTransform::Run) must -+// lock LcmsMutex(). -+ - Status ColorEncoding::SetFieldsFromICC() { - // In case parsing fails, mark the ColorEncoding as invalid. - SetColorSpace(ColorSpace::kUnknown); -@@ -917,6 +929,7 @@ Status ColorEncoding::SetFieldsFromICC() - DetectTransferFunction(profile, this); - #else // JPEGXL_ENABLE_SKCMS - -+ std::lock_guard guard(LcmsMutex()); - const cmsContext context = GetContext(); - - Profile profile; -@@ -984,6 +997,7 @@ void JxlCmsDestroy(void* cms_data) { - if (cms_data == nullptr) return; - JxlCms* t = reinterpret_cast(cms_data); - #if !JPEGXL_ENABLE_SKCMS -+ std::lock_guard guard(LcmsMutex()); - TransformDeleter()(t->lcms_transform); - #endif - delete t; -@@ -1020,6 +1034,7 @@ void* JxlCmsInit(void* init_data, size_t - return nullptr; - } - #else // JPEGXL_ENABLE_SKCMS -+ std::lock_guard guard(LcmsMutex()); - const cmsContext context = GetContext(); - Profile profile_src, profile_dst; - if (!DecodeProfile(context, c_src.ICC(), &profile_src)) { -Index: libjxl-0.8.1/third_party/CMakeLists.txt -=================================================================== ---- libjxl-0.8.1.orig/third_party/CMakeLists.txt -+++ libjxl-0.8.1/third_party/CMakeLists.txt -@@ -111,7 +111,7 @@ if (JPEGXL_ENABLE_SKCMS OR JPEGXL_ENABLE - endif () - if (JPEGXL_ENABLE_VIEWERS OR NOT JPEGXL_ENABLE_SKCMS) - if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lcms/.git" OR JPEGXL_FORCE_SYSTEM_LCMS2 ) -- find_package(LCMS2 2.13) -+ find_package(LCMS2 2.10) - if ( NOT LCMS2_FOUND ) - message(FATAL_ERROR "Please install lcms2 or run git submodule update --init") - endif () -Index: libjxl-0.8.1/third_party/lcms2.cmake -=================================================================== ---- libjxl-0.8.1.orig/third_party/lcms2.cmake -+++ libjxl-0.8.1/third_party/lcms2.cmake -@@ -60,18 +60,4 @@ target_compile_definitions(lcms2 - target_compile_definitions(lcms2 - PUBLIC "-DCMS_NO_REGISTER_KEYWORD=1") - --# Ensure that a thread safe alternative of gmtime is used in LCMS --include(CheckSymbolExists) --check_symbol_exists(gmtime_r "time.h" HAVE_GMTIME_R) --if (HAVE_GMTIME_R) -- target_compile_definitions(lcms2 -- PUBLIC "-DHAVE_GMTIME_R=1") --else() -- check_symbol_exists(gmtime_s "time.h" HAVE_GMTIME_S) -- if (HAVE_GMTIME_S) -- target_compile_definitions(lcms2 -- PUBLIC "-DHAVE_GMTIME_S=1") -- endif() --endif() -- - set_property(TARGET lcms2 PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..6bf7c9f --- /dev/null +++ b/_multibuild @@ -0,0 +1,3 @@ + + gtk + diff --git a/_service b/_service new file mode 100644 index 0000000..f0d2976 --- /dev/null +++ b/_service @@ -0,0 +1,11 @@ + + + git + https://github.com/libjxl/libjxl.git/ + enable + third_party/skcms + v0.8.2 + skcms + _none_ + + diff --git a/libjxl.changes b/libjxl.changes index f044cfe..74873b2 100644 --- a/libjxl.changes +++ b/libjxl.changes @@ -1,3 +1,25 @@ +------------------------------------------------------------------- +Thu Sep 21 13:34:05 UTC 2023 - Jan Engelhardt + +- Switch from LCMS to SKCMS: libjxl core can use either, but + plugins can only use SKCMS. Exercising two CMS simultaneously + also is silly. Delete 0001-Remove-LCMS-mutex.patch . + +------------------------------------------------------------------- +Sat Sep 16 06:58:55 UTC 2023 - Atri Bhattacharya + +- Build plugins: + * Add _service file to generate skcms tarball (needed to build + plugins). + * Add skcms tarball as source and copy extracted dir to + ./third_party/ so cmake can find it. + * Split out new packages: + * gdk-pixbuf-loader-jxl: Pixbuf loader for supported apps. + * gimp-plugin-jxl: Plugin to allow gimp to work with JPEG XL + files. + * jxl-thumbnailer: Thumbnailer and mime files to allow + generating thumbnails for JPEG XL files. + ------------------------------------------------------------------- Wed Jun 14 13:00:09 UTC 2023 - Jan Engelhardt diff --git a/libjxl.spec b/libjxl.spec index add6d4e..ee414f8 100644 --- a/libjxl.spec +++ b/libjxl.spec @@ -1,5 +1,5 @@ # -# spec file for package libjxl +# spec file for package libjxl-gtk # # Copyright (c) 2023 SUSE LLC # @@ -16,8 +16,14 @@ # -Name: libjxl %define lname libjxl0_8 +%if "@BUILD_FLAVOR@" == "gtk" +Name: libjxl-gtk +%bcond_without gtk +%else +Name: libjxl +%bcond_with gtk +%endif Version: 0.8.2 Release: 0 Summary: JPEG XL reference implementation @@ -26,11 +32,15 @@ URL: https://jpegxl.info/ #Git-Clone: https://github.com/libjxl/libjxl Source: https://github.com/libjxl/libjxl/archive/refs/tags/v%version.tar.gz Source1: baselibs.conf -Patch0: 0001-Remove-LCMS-mutex.patch +Source2: skcms.tar BuildRequires: c++_compiler BuildRequires: cmake BuildRequires: pkg-config -BuildRequires: pkgconfig(lcms2) >= 2.10 +%if %{with gtk} +BuildRequires: pkgconfig(gdk-pixbuf-2.0) >= 2.36 +BuildRequires: pkgconfig(gimp-2.0) >= 2.10 +BuildRequires: pkgconfig(gimpui-2.0) >= 2.10 +%endif BuildRequires: pkgconfig(libbrotlicommon) BuildRequires: pkgconfig(libbrotlidec) BuildRequires: pkgconfig(libbrotlienc) @@ -38,6 +48,9 @@ BuildRequires: pkgconfig(libhwy) >= 1.0 BuildRequires: pkgconfig(libjpeg) BuildRequires: pkgconfig(libpng) %{?suse_build_hwcaps_libs} +%if %{with gtk} +Provides: bundled(skcms) = 0 +%endif %description JPEG XL is a raster-graphics file format that supports both lossy and @@ -68,32 +81,62 @@ Summary: Command-line utilities to convert from/to JPEG XL %description tools Command-line utilities to convert from/to JPEG XL. -%prep -%setup -q - -%if %{pkg_vcmp liblcms2-2 < 2.13} -# libjxl 0.7.0 requires lcms2 >= 2.13, so if we have an older version -# (as in SLE15/Leap) just reverse the patch that adds that dependency -%patch0 -p1 -%else -# Make sure patch at least applies -%patch0 -p1 -%patch0 -p1 -R +%package -n gdk-pixbuf-loader-jxl +Summary: A gdk-pixbuf loader for JPEG-XL using libjxl +Supplements: (%lname and gdk-pixbuf) +%if %{with gtk} +%gdk_pixbuf_loader_requires %endif +%description -n gdk-pixbuf-loader-jxl +This package provides a libjxl-based gdk-pixbuf loader for JPEG XL files. + +%package -n gimp-plugin-jxl +Summary: Plugin for GIMP to enable working with JPEG XL files +Supplements: (%lname and gimp) + +%description -n gimp-plugin-jxl +This package provides a plugin for GIMP 2.0 to enable it to work with JPEG XL files. + +%package -n jxl-thumbnailer +Summary: Generate thumbnails for JPEG XL files +BuildArch: noarch + +%description -n jxl-thumbnailer +This package provides a thumbnailer to render for JPEG XL file thumbnails, +for example, on file-browsers. + +%prep +%setup -n libjxl-%version -a2 +mv skcms third_party/ + %build %cmake -DJPEGXL_FORCE_SYSTEM_HWY=ON -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ - -DJPEGXL_FORCE_SYSTEM_LCMS2=ON -DBUILD_TESTING=OFF \ - -DJPEGXL_ENABLE_PLUGINS=OFF -DJPEGXL_ENABLE_SKCMS=OFF \ + -DJPEGXL_FORCE_SYSTEM_LCMS2=OFF -DBUILD_TESTING=OFF \ +%if %{with gtk} + -DJPEGXL_ENABLE_PLUGINS=ON -DJPEGXL_ENABLE_SKCMS=ON \ +%endif -DJPEGXL_ENABLE_SJPEG=OFF %cmake_build %install %cmake_install -rm -fv %buildroot/%_libdir/*.a +b="%buildroot" +rm -fv "$b/%_libdir"/*.a +%if %{with gtk} +rm -Rf "$b/%_libdir"/libjxl* "$b/%_bindir" "$b/%_includedir" "$b/%_libdir/pkgconfig" +%endif %ldconfig_scriptlets -n %lname +%post -n gdk-pixbuf-loader-jxl +%gdk_pixbuf_loader_post + +%postun -n gdk-pixbuf-loader-jxl +%gdk_pixbuf_loader_postun + +%if %{without gtk} + %files -n %lname %license LICENSE %_libdir/libjxl*.so.* @@ -108,4 +151,19 @@ rm -fv %buildroot/%_libdir/*.a %_libdir/libjxl_threads.so %_libdir/pkgconfig/*.pc +%else + +%files -n gdk-pixbuf-loader-jxl +%_libdir/gdk-pixbuf-2.0/*/loaders/libpixbufloader-jxl.so + +%files -n gimp-plugin-jxl +%_libdir/gimp/2.0/plug-ins/file-jxl/ + +%files -n jxl-thumbnailer +%dir %_datadir/thumbnailers +%_datadir/thumbnailers/*.thumbnailer +%_datadir/mime/packages/*.xml + +%endif + %changelog diff --git a/skcms.tar b/skcms.tar new file mode 100644 index 0000000..e4cc563 --- /dev/null +++ b/skcms.tar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8335d994cd09b5a8456e6cd9f3ac94933337925aa918d525d91ee0ef4b732212 +size 14899200