1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-12 18:59:50 +03:00

community/libjxl: upgrade to 0.11.1

This commit is contained in:
Sertonix 2025-07-06 01:43:53 +02:00 committed by achill (fossdd)
parent f8ae04c86c
commit dc82269d0e
3 changed files with 125 additions and 38 deletions

View file

@ -1,11 +1,11 @@
# Maintainer: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
pkgname=libjxl
pkgver=0.10.3
pkgrel=2
_testdata_commit=873045a9c42ed60721756e26e2a6b32e17415205
pkgver=0.11.1
pkgrel=0
_testdata_commit=73695d303670c90e4d506ea89d9901b081385089
pkgdesc="JPEG XL image format reference implementation"
url="https://jpeg.org/jpegxl/"
# s390x fails like most of the tests, implying it's broken (even without llvm/lld)
# s390x fails 21 tests
arch="all !s390x"
license="Apache-2.0"
makedepends="
@ -30,34 +30,26 @@ makedepends="
subpackages="$pkgname-doc $pkgname-tools $pkgname-dev $pkgname-pixbuf-loader"
source="https://github.com/libjxl/libjxl/archive/v$pkgver/libjxl-v$pkgver.tar.gz
libjxl-testdata-$_testdata_commit.tar.gz::https://github.com/libjxl/testdata/archive/$_testdata_commit.tar.gz
no-werror.patch
openexr.patch
"
# with -fstack-clash-protection/-D_GLIBCXX_ASSERTIONS, a lot of these just segfault
case "$CARCH" in
x86) options="$options !check" ;;
esac
# secfixes:
# 0.11.1-r0:
# - CVE-2024-11403
# - CVE-2024-11498
prepare() {
default_prepare
rmdir testdata
ln -sfv "$srcdir"/testdata-$_testdata_commit testdata
rmdir third_party/skcms
}
build() {
case "$CARCH" in
riscv64|ppc64le)
;;
*)
# fails on riscv/test fail on ppc64le
export CFLAGS="$CFLAGS -flto=thin"
export CXXFLAGS="$CXXFLAGS -flto=thin"
export CC=clang
export CXX=clang++
export LDFLAGS="$LDFLAGS -fuse-ld=lld"
;;
esac
export CFLAGS="$CFLAGS -flto=thin"
export CXXFLAGS="$CXXFLAGS -flto=thin"
export CC=clang
export CXX=clang++
export LDFLAGS="$LDFLAGS -fuse-ld=lld"
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
@ -75,12 +67,14 @@ build() {
-DJPEGXL_ENABLE_VIEWERS=OFF \
-DJPEGXL_FORCE_SYSTEM_GTEST=ON \
-DJPEGXL_FORCE_SYSTEM_BROTLI=ON \
-DJPEGXL_FORCE_SYSTEM_HWY=ON
-DJPEGXL_FORCE_SYSTEM_HWY=ON \
-DJPEGXL_FORCE_SYSTEM_LCMS2=ON
cmake --build build
}
check() {
ctest --test-dir build -E 'CodecTest.TestRoundTrip'
# FIXME SIGTRAP/SIGILL (probably assertion)
ctest --test-dir build -E 'SplinesTest.Drawing'
}
package() {
@ -103,7 +97,7 @@ loader() {
}
sha512sums="
5ece482f4c5f0312e87e020f921525622a6d3f1a3834f3cd8666638fc8d0fba8cd072ef58f7b153dc17ca19071ebae2fbad7b08e6d440c2669f4f1b35888a7d4 libjxl-v0.10.3.tar.gz
31bfccc8421e98cb80cea111ead0ea7d14016c77ad10fd804d783419e61892257688e1fcf89f956166e3242b522349ad22da985b96a9d3129c66be2aa60793b6 libjxl-testdata-873045a9c42ed60721756e26e2a6b32e17415205.tar.gz
a99668ca0dbb3b9827341c3f7f8b93a109b46b759c40da6652cc1cd0fa597e0e1040392af09f3d19645ec8baccc68c37deb634b6d9975298427ccb797a2adcb3 no-werror.patch
0cfd81d9d3b783f96bd04f244d73ffbc12186c89993d46064a2751bef0a446a5e86be05add5c10f60d4482d39333d9bf3f9a866d6eb84f8fa0d4e8b5828fd74c libjxl-v0.11.1.tar.gz
8c02a1b7752da9ec93c228436c4bbcdafb5b655e6386a76cf9ccfc4b1c5d4614d9ec3b9931281a57a5348720d4641ff518cb6ed9e06a5dcb0725fd9fda138618 libjxl-testdata-73695d303670c90e4d506ea89d9901b081385089.tar.gz
0aaf9aae8569d04cd4be367e79eb1b9282b051dcbddef6df5b6c4b12aa08f40800c4f8a5606c1987b5af926108b035821c845770c7d8748364d75ddc5745abe0 openexr.patch
"

View file

@ -1,11 +0,0 @@
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -403,7 +403,7 @@ endif() # SANITIZER != "none"
set_target_properties(libjxl_test PROPERTIES PREFIX "tests/")
target_link_libraries(libjxl_test jxl)
if (NOT MSVC)
-target_compile_options(libjxl_test PRIVATE -Wall -Wextra -Werror)
+target_compile_options(libjxl_test PRIVATE -Wall -Wextra)
if(NOT WIN32)
target_compile_options(libjxl_test PRIVATE -pedantic)
endif() # NOT WIN32

View file

@ -0,0 +1,104 @@
Patch-Source: https://github.com/libjxl/libjxl/commit/d2411cebb0c34927189417dfc536867fa8902b22
From d2411cebb0c34927189417dfc536867fa8902b22 Mon Sep 17 00:00:00 2001
From: Eugene Kliuchnikov <eustas@google.com>
Date: Wed, 11 Dec 2024 18:48:12 +0100
Subject: [PATCH] Fix for newer versions of OpenEXR (#4007)
Newer versions of OpenEXR are doing "scratch" reads that can span befind end of file
(and thus misuse exceptions)
This PR adjusts our InMemoryIStream to fit OpenEXR expectations.
---
lib/extras/codec_test.cc | 14 +++++++++-----
lib/extras/dec/exr.cc | 28 +++++++++++++++++++++-------
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/lib/extras/codec_test.cc b/lib/extras/codec_test.cc
index 6cbed220975..c2b656bd6c2 100644
--- a/lib/extras/codec_test.cc
+++ b/lib/extras/codec_test.cc
@@ -267,15 +267,19 @@ void TestRoundTrip(const TestImageParams& params, ThreadPool* pool) {
params.codec, params.is_gray, params.add_alpha, params.bits_per_sample);
printf("Codec %s %s\n", extension.c_str(), params.DebugString().c_str());
- PackedPixelFile ppf_in;
- CreateTestImage(params, &ppf_in);
-
- EncodedImage encoded;
+ if (!CanDecode(params.codec)) {
+ fprintf(stderr, "Skipping test because of missing decoding support.\n");
+ return;
+ }
auto encoder = Encoder::FromExtension(extension);
if (!encoder) {
- fprintf(stderr, "Skipping test because of missing codec support.\n");
+ fprintf(stderr, "Skipping test because of missing encoding support.\n");
return;
}
+
+ PackedPixelFile ppf_in;
+ CreateTestImage(params, &ppf_in);
+ EncodedImage encoded;
ASSERT_TRUE(encoder->Encode(ppf_in, &encoded, pool));
ASSERT_EQ(encoded.bitstreams.size(), 1);
diff --git a/lib/extras/dec/exr.cc b/lib/extras/dec/exr.cc
index 59edd63eb86..4213d8ec577 100644
--- a/lib/extras/dec/exr.cc
+++ b/lib/extras/dec/exr.cc
@@ -41,10 +41,9 @@ Status DecodeImageEXR(Span<const uint8_t> bytes, const ColorHints& color_hints,
#include <vector>
#ifdef __EXCEPTIONS
-#include <stdexcept>
-#define JXL_EXR_THROW_LENGTH_ERROR() throw std::length_error("");
+#define JXL_EXR_THROW_LENGTH_ERROR(M) throw Iex::InputExc(M);
#else // __EXCEPTIONS
-#define JXL_EXR_THROW_LENGTH_ERROR() JXL_CRASH()
+#define JXL_EXR_THROW_LENGTH_ERROR(M) JXL_CRASH()
#endif // __EXCEPTIONS
namespace jxl {
@@ -71,8 +70,11 @@ class InMemoryIStream : public OpenEXR::IStream {
bool isMemoryMapped() const override { return true; }
char* readMemoryMapped(const int n) override {
- if (pos_ + n < pos_ || pos_ + n > bytes_.size()) {
- JXL_EXR_THROW_LENGTH_ERROR();
+ if (pos_ + n < pos_) {
+ JXL_EXR_THROW_LENGTH_ERROR("Overflow");
+ }
+ if (pos_ + n > bytes_.size()) {
+ JXL_EXR_THROW_LENGTH_ERROR("Read past end of file");
}
char* const result =
const_cast<char*>(reinterpret_cast<const char*>(bytes_.data() + pos_));
@@ -80,14 +82,26 @@ class InMemoryIStream : public OpenEXR::IStream {
return result;
}
bool read(char c[], const int n) override {
- std::copy_n(readMemoryMapped(n), n, c);
+ // That is not stated in documentation, but the OpenEXR code expects that
+ // when requested amount is not accessible and exception is thrown, all
+ // the accessible data is read.
+ if (pos_ + n < pos_) {
+ JXL_EXR_THROW_LENGTH_ERROR("Overflow");
+ }
+ if (pos_ + n > bytes_.size()) {
+ int can_read = static_cast<int>(bytes_.size() - pos_);
+ std::copy_n(readMemoryMapped(can_read), can_read, c);
+ JXL_EXR_THROW_LENGTH_ERROR("Read past end of file");
+ } else {
+ std::copy_n(readMemoryMapped(n), n, c);
+ }
return pos_ < bytes_.size();
}
ExrInt64 tellg() override { return pos_; }
void seekg(const ExrInt64 pos) override {
if (pos >= bytes_.size()) {
- JXL_EXR_THROW_LENGTH_ERROR();
+ JXL_EXR_THROW_LENGTH_ERROR("Seeks past end of file");
}
pos_ = pos;
}