SHA256
1
0
forked from pool/libjxl

Accepting request 1113235 from graphics

- Build plugins:

OBS-URL: https://build.opensuse.org/request/show/1113235
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libjxl?expand=0&rev=11
This commit is contained in:
Ana Guerrero 2023-09-25 17:59:57 +00:00 committed by Git OBS Bridge
commit 7322d69af3
7 changed files with 117 additions and 135 deletions

2
.gitattributes vendored
View File

@ -21,3 +21,5 @@
*.xz filter=lfs diff=lfs merge=lfs -text *.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text
*.zst 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

View File

@ -1,117 +0,0 @@
From 057cd06c19875bcf8b5d34d41d92a8abdb856b7c Mon Sep 17 00:00:00 2001
From: Kleis Auke Wolthuizen <github@kleisauke.nl>
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 <array>
#include <atomic>
#include <memory>
+#include <mutex>
#include <string>
#include <utility>
@@ -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<std::mutex> 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<JxlCms*>(cms_data);
#if !JPEGXL_ENABLE_SKCMS
+ std::lock_guard<std::mutex> 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<std::mutex> 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)

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<flavor>gtk</flavor>
</multibuild>

11
_service Normal file
View File

@ -0,0 +1,11 @@
<services>
<service name="tar_scm" mode="manual">
<param name="scm">git</param>
<param name="url">https://github.com/libjxl/libjxl.git/</param>
<param name="submodules">enable</param>
<param name="subdir">third_party/skcms</param>
<param name="revision">v0.8.2</param>
<param name="filename">skcms</param>
<param name="version">_none_</param>
</service>
</services>

View File

@ -1,3 +1,25 @@
-------------------------------------------------------------------
Thu Sep 21 13:34:05 UTC 2023 - Jan Engelhardt <jengelh@inai.de>
- 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 <badshah400@gmail.com>
- 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 <jengelh@inai.de> Wed Jun 14 13:00:09 UTC 2023 - Jan Engelhardt <jengelh@inai.de>

View File

@ -1,5 +1,5 @@
# #
# spec file for package libjxl # spec file for package libjxl-gtk
# #
# Copyright (c) 2023 SUSE LLC # Copyright (c) 2023 SUSE LLC
# #
@ -16,8 +16,14 @@
# #
Name: libjxl
%define lname libjxl0_8 %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 Version: 0.8.2
Release: 0 Release: 0
Summary: JPEG XL reference implementation Summary: JPEG XL reference implementation
@ -26,11 +32,15 @@ URL: https://jpegxl.info/
#Git-Clone: https://github.com/libjxl/libjxl #Git-Clone: https://github.com/libjxl/libjxl
Source: https://github.com/libjxl/libjxl/archive/refs/tags/v%version.tar.gz Source: https://github.com/libjxl/libjxl/archive/refs/tags/v%version.tar.gz
Source1: baselibs.conf Source1: baselibs.conf
Patch0: 0001-Remove-LCMS-mutex.patch Source2: skcms.tar
BuildRequires: c++_compiler BuildRequires: c++_compiler
BuildRequires: cmake BuildRequires: cmake
BuildRequires: pkg-config 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(libbrotlicommon)
BuildRequires: pkgconfig(libbrotlidec) BuildRequires: pkgconfig(libbrotlidec)
BuildRequires: pkgconfig(libbrotlienc) BuildRequires: pkgconfig(libbrotlienc)
@ -38,6 +48,9 @@ BuildRequires: pkgconfig(libhwy) >= 1.0
BuildRequires: pkgconfig(libjpeg) BuildRequires: pkgconfig(libjpeg)
BuildRequires: pkgconfig(libpng) BuildRequires: pkgconfig(libpng)
%{?suse_build_hwcaps_libs} %{?suse_build_hwcaps_libs}
%if %{with gtk}
Provides: bundled(skcms) = 0
%endif
%description %description
JPEG XL is a raster-graphics file format that supports both lossy and 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 %description tools
Command-line utilities to convert from/to JPEG XL. Command-line utilities to convert from/to JPEG XL.
%prep %package -n gdk-pixbuf-loader-jxl
%setup -q Summary: A gdk-pixbuf loader for JPEG-XL using libjxl
Supplements: (%lname and gdk-pixbuf)
%if %{pkg_vcmp liblcms2-2 < 2.13} %if %{with gtk}
# libjxl 0.7.0 requires lcms2 >= 2.13, so if we have an older version %gdk_pixbuf_loader_requires
# (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
%endif %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 %build
%cmake -DJPEGXL_FORCE_SYSTEM_HWY=ON -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ %cmake -DJPEGXL_FORCE_SYSTEM_HWY=ON -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \
-DJPEGXL_FORCE_SYSTEM_LCMS2=ON -DBUILD_TESTING=OFF \ -DJPEGXL_FORCE_SYSTEM_LCMS2=OFF -DBUILD_TESTING=OFF \
-DJPEGXL_ENABLE_PLUGINS=OFF -DJPEGXL_ENABLE_SKCMS=OFF \ %if %{with gtk}
-DJPEGXL_ENABLE_PLUGINS=ON -DJPEGXL_ENABLE_SKCMS=ON \
%endif
-DJPEGXL_ENABLE_SJPEG=OFF -DJPEGXL_ENABLE_SJPEG=OFF
%cmake_build %cmake_build
%install %install
%cmake_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 %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 %files -n %lname
%license LICENSE %license LICENSE
%_libdir/libjxl*.so.* %_libdir/libjxl*.so.*
@ -108,4 +151,19 @@ rm -fv %buildroot/%_libdir/*.a
%_libdir/libjxl_threads.so %_libdir/libjxl_threads.so
%_libdir/pkgconfig/*.pc %_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 %changelog

3
skcms.tar Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8335d994cd09b5a8456e6cd9f3ac94933337925aa918d525d91ee0ef4b732212
size 14899200