From 926c1af2b4c91f5c0efe9b88a987e10f61ba4be0 Mon Sep 17 00:00:00 2001 From: Frankie Dintino Date: Sun, 14 Jul 2024 09:15:11 -0400 Subject: [PATCH] fix: macOS arm64 illegal instruction segmentation fault with aom encoding (#60) This updates the libavif sha to incorporate the fix in AOMediaCodec/libavif#2265 --- .github/workflows/test.yml | 1 - tests/test_file_avif.py | 12 ++++++++++++ wheelbuild/config.sh | 6 +++--- winbuild/build_prepare.py | 6 +++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 28f6015..7e91b8d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,7 +67,6 @@ jobs: ${{ env.LIBAVIF_VERSION }}-${{ hashFiles('.github/workflows/*.sh', '.github/workflows/test.yml', 'depends/*') }}-${{ matrix.os }} - name: Install nasm - if: steps.build-cache.outputs.cache-hit != 'true' uses: ilammy/setup-nasm@v1 with: version: 2.15.05 diff --git a/tests/test_file_avif.py b/tests/test_file_avif.py index a6ef23e..23f2302 100644 --- a/tests/test_file_avif.py +++ b/tests/test_file_avif.py @@ -584,6 +584,18 @@ def test_decoder_strict_flags(self): with Image.open("%s/tests/images/chimera-missing-pixi.avif" % CURR_DIR) as im: assert im.size == (480, 270) + @skip_unless_avif_encoder("aom") + def test_aom_optimizations(self): + im = hopper("RGB") + buf = BytesIO() + im.save(buf, format="AVIF", codec="aom", speed=1) + + @skip_unless_avif_encoder("svt") + def test_svt_optimizations(self): + im = hopper("RGB") + buf = BytesIO() + im.save(buf, format="AVIF", codec="svt", speed=1) + class TestAvifAnimation: @contextmanager diff --git a/wheelbuild/config.sh b/wheelbuild/config.sh index 523f5bb..e158aeb 100644 --- a/wheelbuild/config.sh +++ b/wheelbuild/config.sh @@ -4,7 +4,7 @@ set -eo pipefail CONFIG_DIR=$(abspath $(dirname "${BASH_SOURCE[0]}")) ARCHIVE_SDIR=pillow-avif-plugin-depends -LIBAVIF_VERSION=e10e6d98e6d1dbcdd409859a924d1b607a1e06dc +LIBAVIF_VERSION=02fc53e73d68dccacc54ce543b1be1e9b3236495 RAV1E_VERSION=0.7.1 CCACHE_VERSION=4.7.1 SCCACHE_VERSION=0.3.0 @@ -229,7 +229,7 @@ function build_libavif { cmake --version if [ -n "$IS_MACOS" ] && [ "$PLAT" == "arm64" ]; then # SVT-AV1 NEON intrinsics require macOS 14 - local macos_ver==$(sw_vers --productVersion | sed 's/\.[0-9]*//') + local macos_ver=$(sw_vers --productVersion | sed 's/\.[0-9]*//') if [ "$macos_ver" -gt "13" ]; then LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_SVT=LOCAL) fi @@ -270,7 +270,7 @@ EOF group_start "Download libavif source" fetch_unpack \ - "https://github.com/AOMediaCodec/libavif/archive/$LIBAVIF_VERSION.tar.gz" \ + "https://github.com/fdintino/libavif/archive/$LIBAVIF_VERSION.tar.gz" \ "libavif-$LIBAVIF_VERSION.tar.gz" group_end diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 28faa49..b3ac6c3 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -181,10 +181,10 @@ def cmd_msbuild( "libavif": { "url": ( "https://github.com/fdintino/libavif/archive/" - "e10e6d98e6d1dbcdd409859a924d1b607a1e06dc.zip" + "02fc53e73d68dccacc54ce543b1be1e9b3236495.zip" ), - "filename": "libavif-e10e6d98e6d1dbcdd409859a924d1b607a1e06dc.zip", - "dir": "libavif-e10e6d98e6d1dbcdd409859a924d1b607a1e06dc", + "filename": "libavif-02fc53e73d68dccacc54ce543b1be1e9b3236495.zip", + "dir": "libavif-02fc53e73d68dccacc54ce543b1be1e9b3236495", "license": "LICENSE", "build": [ cmd_mkdir("build.pillow"),