diff --git a/.github/workflows/linux-install.sh b/.github/workflows/linux-install.sh index abb8cc0..37271db 100755 --- a/.github/workflows/linux-install.sh +++ b/.github/workflows/linux-install.sh @@ -2,6 +2,15 @@ set -eo pipefail +aptget() +{ + if [ $(id -u) == 0 ]; then + apt-get "$@" + else + sudo apt-get "$@" + fi +} + aptget_update() { if [ ! -z $1 ]; then @@ -9,7 +18,7 @@ aptget_update() echo "Retrying apt-get update..." echo "" fi - output=`sudo apt-get update 2>&1` + output=`aptget update 2>&1` echo "$output" if [[ $output == *[WE]:\ * ]]; then return 1 @@ -19,11 +28,12 @@ aptget_update || aptget_update retry || aptget_update retry set -e -sudo apt-get -qq install zlib1g-dev libpng-dev libjpeg-dev \ +aptget -qq install zlib1g-dev libpng-dev libjpeg-dev sudo \ libxml2-dev libffi-dev libxslt-dev cmake ninja-build nasm if [ "$GHA_PYTHON_VERSION" == "2.7" ]; then python2 -m pip install tox tox-gh-actions + aptget install -y python3-pip else python3 -m pip install 'tox<4' tox-gh-actions fi diff --git a/.github/workflows/macos-install.sh b/.github/workflows/macos-install.sh index b05060c..6ceab1e 100755 --- a/.github/workflows/macos-install.sh +++ b/.github/workflows/macos-install.sh @@ -2,7 +2,8 @@ set -e -brew install dav1d aom rav1e cmake +brew reinstall cmake +brew install dav1d aom rav1e if [ "$GHA_PYTHON_VERSION" == "2.7" ]; then python2 -m pip install -U tox tox-gh-actions diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d330e92..8c0d4ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,11 @@ jobs: "3.7", "2.7", ] + libavif-version: [ "0.11.0" ] include: + - python-version: "3.9" + os: "ubuntu-20.04" + libavif-version: "1.0.1" - python-version: "3.7" PYTHONOPTIMIZE: 1 - python-version: "3.8" @@ -30,17 +34,23 @@ jobs: codecov-flag: GHA_Ubuntu - os: macos-11 codecov-flag: GHA_macOS + exclude: + - python-version: "2.7" + os: "macos-11" runs-on: ${{ matrix.os }} - name: ${{ matrix.os }} Python ${{ matrix.python-version }} + name: ${{ matrix.os }} Python ${{ matrix.python-version }} (libavif ${{ matrix.libavif-version }}) + container: + image: ${{ matrix.python-version == '2.7' && 'python:2.7-buster' || null }} env: - LIBAVIF_VERSION: 0.11.0 + LIBAVIF_VERSION: ${{ matrix.libavif-version }} steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} + if: matrix.python-version != '2.7' uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -75,7 +85,6 @@ jobs: if: failure() run: | mkdir -p tests/errors - shell: pwsh - name: Upload errors uses: actions/upload-artifact@v3 @@ -90,83 +99,69 @@ jobs: CODECOV_NAME: ${{ matrix.os }} Python ${{ matrix.python-version }} - name: Upload coverage - run: tox -e codecov -- -F ${{ matrix.codecov-flag }} - env: - CODECOV_NAME: ${{ matrix.os }} Python ${{ matrix.python-version }} + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml msys: - runs-on: windows-2019 - - strategy: - fail-fast: false - matrix: - msystem: [ "mingw32", "mingw64" ] - python-version: ["2", "3"] - include: - - msystem: "mingw32" - name: "MSYS2 MinGW 32-bit" - package: "mingw-w64-i686" - env: i686 - - msystem: "mingw64" - name: "MSYS2 MinGW 64-bit" - package: "mingw-w64-x86_64" - env: x86_64 - exclude: - - msystem: "mingw32" - python-version: "2" + runs-on: windows-latest - name: ${{ matrix.name }} python ${{ matrix.python-version }} + name: MinGW defaults: run: - shell: msys2 {0} + shell: bash.exe --login -eo pipefail "{0}" env: - MSYSTEM: ${{ matrix.msystem }} + MSYSTEM: MINGW64 CHERE_INVOKING: 1 + SETUPTOOLS_USE_DISTUTILS: stdlib timeout-minutes: 30 steps: - uses: actions/checkout@v3 - - uses: msys2/setup-msys2@v2 - with: - msystem: ${{ matrix.msystem }} - update: true - install: >- - base-devel - git - ${{ matrix.package }}-toolchain - ${{ matrix.package }}-python${{ matrix.python-version }}-pip - ${{ matrix.package }}-python${{ matrix.python-version }}-setuptools - ${{ matrix.package }}-libjpeg-turbo - ${{ matrix.package }}-libtiff - ${{ matrix.package }}-libpng - ${{ matrix.package }}-openjpeg2 - ${{ matrix.package }}-libavif + - name: Set up shell + run: echo "C:\msys64\usr\bin\" >> $env:GITHUB_PATH + shell: pwsh + + - name: Install dependencies + run: | + pacman -S --noconfirm \ + base-devel \ + git \ + mingw-w64-x86_64-gcc \ + mingw-w64-x86_64-toolchain \ + mingw-w64-x86_64-python3-pip \ + mingw-w64-x86_64-python3-setuptools \ + mingw-w64-x86_64-libjpeg-turbo \ + mingw-w64-x86_64-libtiff \ + mingw-w64-x86_64-libpng \ + mingw-w64-x86_64-openjpeg2 \ + mingw-w64-x86_64-zlib \ + mingw-w64-x86_64-libavif - name: Install Dependencies run: | - python${{ matrix.python-version }} -m pip install pytest pytest-cov pillow mock + python3 -m pip install pytest pytest-cov pillow mock - name: Build pillow-avif-plugin - run: CFLAGS="-coverage" python${{ matrix.python-version }} setup.py build_ext install + run: CFLAGS="-coverage" python3 -m pip install . - name: Test pillow-avif-plugin run: | - python${{ matrix.python-version }} -m pytest -vx --cov pillow_avif --cov tests --cov-report term --cov-report xml tests + python3 -m pytest -vx --cov pillow_avif --cov tests --cov-report term --cov-report xml tests - name: Upload coverage - run: | - python${{ matrix.python-version }} -m pip install codecov - bash <(curl -s https://codecov.io/bash) -F GHA_Windows - env: - CODECOV_NAME: ${{ matrix.name }} - + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + flags: GHA_Windows + name: "MSYS2 MinGW" success: needs: [build, msys] - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest name: Test Successful steps: - name: Success diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 28a3e5a..e4b17fa 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -20,20 +20,12 @@ jobs: matrix: os: [ "ubuntu-20.04", "macos-11" ] python: [ "2.7", "3.7", "3.8", "3.9", "3.10", "3.11" ] - platform: [ "x86_64", "i686" ] - manylinux-version: [ "1", "2010" ] + platform: [ "x86_64" ] + manylinux-version: [ "2010" ] macos-target: [ "10.10" ] mb-ml-libc: [ "manylinux" ] multibuild-sha: [ "34e970c4bc448b73af0127615fc4583b4f247369" ] exclude: - - os: "macos-11" - platform: "i686" - - os: "macos-11" - manylinux-version: "1" - - python: "3.10" - manylinux-version: "1" - - python: "3.11" - manylinux-version: "1" - python: "3.11" manylinux-version: "2010" - python: "3.11" @@ -41,9 +33,6 @@ jobs: include: - os: "macos-11" os-name: "osx" - - os: "ubuntu-20.04" - manylinux-version: "1" - os-name: "manylinux1" - os: "ubuntu-20.04" manylinux-version: "2010" os-name: "manylinux2010" @@ -136,12 +125,6 @@ jobs: os-name: "manylinux2014" manylinux-version: "2014" multibuild-sha: "bb32cfec4f755cb146332a0490abcf3187ce61d1" - - python: "3.11" - platform: "i686" - os: "ubuntu-20.04" - os-name: "manylinux2014" - manylinux-version: "2014" - multibuild-sha: "bb32cfec4f755cb146332a0490abcf3187ce61d1" env: BUILD_COMMIT: HEAD PLAT: ${{ matrix.platform }} @@ -222,7 +205,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] architecture: ["x64"] include: - architecture: "x64" diff --git a/depends/install_libavif.sh b/depends/install_libavif.sh index 30ad6dd..831c1d5 100755 --- a/depends/install_libavif.sh +++ b/depends/install_libavif.sh @@ -13,6 +13,8 @@ else PREFIX=/usr fi +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + PKGCONFIG=${PKGCONFIG:-pkg-config} export CFLAGS="-fPIC -O3 $CFLAGS" @@ -26,6 +28,10 @@ curl -sLo - \ pushd libavif-$LIBAVIF_VERSION echo "::endgroup::" +if [ "$LIBAVIF_VERSION" == "1.0.1" ]; then + patch -p1 < "${SCRIPT_DIR}/../wheelbuild/libavif-1.0.1-local-static.patch" +fi + HAS_DECODER=0 HAS_ENCODER=0 diff --git a/src/pillow_avif/AvifImagePlugin.py b/src/pillow_avif/AvifImagePlugin.py index 0b14530..73d0f3c 100644 --- a/src/pillow_avif/AvifImagePlugin.py +++ b/src/pillow_avif/AvifImagePlugin.py @@ -136,7 +136,7 @@ def _save(im, fp, filename, save_all=False): # - qmax is 0 for quality=100, then qmax increases linearly relative to # quality decreasing, until it flattens out at quality=37. quality = info.get("quality", 75) - if not isinstance(quality, int): + if not isinstance(quality, int) or quality < 0 or quality > 100: raise ValueError("Invalid quality setting") qmin = max(0, min(64 - quality, 63)) qmax = max(0, min(100 - quality, 63)) @@ -186,6 +186,7 @@ def _save(im, fp, filename, save_all=False): subsampling, qmin, qmax, + quality, speed, codec, range_, diff --git a/src/pillow_avif/_avif.c b/src/pillow_avif/_avif.c index ff6381e..0728d06 100644 --- a/src/pillow_avif/_avif.c +++ b/src/pillow_avif/_avif.c @@ -13,6 +13,7 @@ typedef struct { avifPixelFormat subsampling; int qmin; int qmax; + int quality; int speed; avifCodecChoice codec; avifRange range; @@ -205,6 +206,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) { char *subsampling = "4:2:0"; int qmin = AVIF_QUANTIZER_BEST_QUALITY; // =0 int qmax = 10; // "High Quality", but not lossless + int quality = 75; int speed = 8; PyObject *icc_bytes; PyObject *exif_bytes; @@ -221,12 +223,13 @@ AvifEncoderNew(PyObject *self_, PyObject *args) { if (!PyArg_ParseTuple( args, - "IIsiiissiiOOSSSO", + "IIsiiiissiiOOSSSO", &width, &height, &subsampling, &qmin, &qmax, + &quality, &speed, &codec, &range, @@ -256,6 +259,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) { enc_options.qmin = normalize_quantize_value(qmin); enc_options.qmax = normalize_quantize_value(qmax); + enc_options.quality = quality; if (speed < AVIF_SPEED_SLOWEST) { speed = AVIF_SPEED_SLOWEST; @@ -321,8 +325,12 @@ AvifEncoderNew(PyObject *self_, PyObject *args) { } encoder->maxThreads = max_threads; +#if AVIF_VERSION >= 1000000 + encoder->quality = enc_options.quality; +#else encoder->minQuantizer = enc_options.qmin; encoder->maxQuantizer = enc_options.qmax; +#endif encoder->codecChoice = enc_options.codec; encoder->speed = enc_options.speed; encoder->timescale = (uint64_t)1000; diff --git a/tox.ini b/tox.ini index 6797669..d5215e6 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,7 @@ envlist = py{27,37,38,39,310,py37} minversion = 1.9 [gh-actions] +problem_matcher = False python = 2.7: py27 3.7: py37 @@ -29,10 +30,10 @@ commands = {envpython} setup.py clean {envpython} setup.py build_ext --build-lib {envdir}/src --build-temp {envdir} develop {envpython} -m pytest -W always {posargs: -vv --cov pillow_avif --cov tests --cov-report term} - - gcovr -r {toxinidir} --object-directory {envdir} -k {envpython} -c "import os; os.path.exists('{toxworkdir}/coverage') or os.makedirs('{toxworkdir}/coverage')" - - gcovr -r {toxinidir} --object-directory {envdir} -k --xml \ - -o {toxworkdir}/coverage/gcov_coverage.{envname}.xml + - gcovr -r {toxinidir} --object-directory {envdir} -k \ + --gcov-ignore-errors=no_working_dir_found \ + -o {toxworkdir}/coverage/.gcov_coverage.{envname} deps = gcovr pytest @@ -50,7 +51,7 @@ changedir = {toxworkdir}/coverage commands = coverage combine coverage report - coverage xml + coverage xml -o {toxinidir}/coverage.xml [testenv:codecov] skip_install = true @@ -59,4 +60,4 @@ depends = coverage-report passenv = CODECOV_TOKEN changedir = {toxinidir} commands = - codecov -X gcov --file {toxworkdir}/coverage/*.xml {posargs} + codecov -X gcov --file {toxinidir}/coverage.xml {posargs} diff --git a/wheelbuild/aom-3.5.0-monochrome-realtime-encode.patch b/wheelbuild/aom-3.5.0-monochrome-realtime-encode.patch deleted file mode 100644 index 07dcd90..0000000 --- a/wheelbuild/aom-3.5.0-monochrome-realtime-encode.patch +++ /dev/null @@ -1,43 +0,0 @@ -From bf9d1f8d2b649ee8a02e6e8792075330bde185d4 Mon Sep 17 00:00:00 2001 -From: James Zern -Date: Thu, 27 Oct 2022 18:17:47 -0700 -Subject: [PATCH] fix monochrome encoding in realtime mode - -this is non-exhaustive, but covers the file in the issue report and the -newly added MonochromeRealtimeTest. - -Bug: https://github.com/AOMediaCodec/libavif/issues/1190 -Change-Id: I947a5d926daaae9c0a667114996ddd7bf9ff2013 ---- - av1/encoder/nonrd_pickmode.c | 3 ++- - av1/encoder/var_based_part.c | 2 +- - test/monochrome_test.cc | 47 +++++++++++++++++++++++++++++------- - 3 files changed, 41 insertions(+), 11 deletions(-) - -diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c -index 7267f9e39b..009b3c360d 100644 ---- a/av1/encoder/nonrd_pickmode.c -+++ b/av1/encoder/nonrd_pickmode.c -@@ -2777,7 +2777,8 @@ void set_color_sensitivity(AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, - x->color_sensitivity[1] = 0; - return; - } -- for (int i = 1; i <= 2; ++i) { -+ const int num_planes = av1_num_planes(&cpi->common); -+ for (int i = 1; i < num_planes; ++i) { - if (x->color_sensitivity[i - 1] == 2 || source_variance < 50) { - struct macroblock_plane *const p = &x->plane[i]; - const BLOCK_SIZE bs = -diff --git a/av1/encoder/var_based_part.c b/av1/encoder/var_based_part.c -index efcb5a71f0..63f807733b 100644 ---- a/av1/encoder/var_based_part.c -+++ b/av1/encoder/var_based_part.c -@@ -1237,7 +1237,7 @@ static void setup_planes(AV1_COMP *cpi, MACROBLOCK *x, unsigned int *y_sad, - set_ref_ptrs(cm, xd, mi->ref_frame[0], mi->ref_frame[1]); - av1_enc_build_inter_predictor(cm, xd, mi_row, mi_col, NULL, - cm->seq_params->sb_size, AOM_PLANE_Y, -- AOM_PLANE_V); -+ num_planes - 1); - } - } - diff --git a/wheelbuild/aom-fix-stack-size.patch b/wheelbuild/aom-fix-stack-size.patch index d8206e8..beaca04 100644 --- a/wheelbuild/aom-fix-stack-size.patch +++ b/wheelbuild/aom-fix-stack-size.patch @@ -68,11 +68,3 @@ index 8d04312..efbed78 100644 typedef CRITICAL_SECTION pthread_mutex_t; #if _WIN32_WINNT < 0x0600 -@@ -147,6 +148,7 @@ - #include // NOLINT - - #define pthread_t TID -+#define pthread_attr_t int - #define pthread_mutex_t HMTX - - typedef struct { diff --git a/wheelbuild/config.sh b/wheelbuild/config.sh index d4ed5b6..6571b70 100644 --- a/wheelbuild/config.sh +++ b/wheelbuild/config.sh @@ -4,13 +4,13 @@ set -eo pipefail CONFIG_DIR=$(abspath $(dirname "${BASH_SOURCE[0]}")) ARCHIVE_SDIR=pillow-avif-plugin-depends -LIBAVIF_VERSION=0.11.0 -AOM_VERSION=3.5.0 -DAV1D_VERSION=1.0.0 -SVT_AV1_VERSION=1.3.0 -RAV1E_VERSION=p20230417 -LIBWEBP_SHA=15a91ab179b0b605727d16fb751c12674da9dfec -LIBYUV_SHA=f9fda6e7 +LIBAVIF_VERSION=1.0.1 +AOM_VERSION=3.7.0 +DAV1D_VERSION=1.2.1 +SVT_AV1_VERSION=1.7.0 +RAV1E_VERSION=p20230911 +LIBWEBP_SHA=e2c85878f6a33f29948b43d3492d9cdaf801aa54 +LIBYUV_SHA=464c51a0 CCACHE_VERSION=4.7.1 SCCACHE_VERSION=0.3.0 export PERLBREWURL=https://raw.githubusercontent.com/gugod/App-perlbrew/release-0.92/perlbrew @@ -66,12 +66,26 @@ if [[ -n "${GITHUB_ACTIONS:-}" ]]; then exec 2>&1 fi +function require_package { + local pkg=$1 + local pkgconfig=${PKGCONFIG:-pkg-config} + if ! $pkgconfig --exists $pkg; then + echo "$pkg failed to build" + exit 1 + fi +} + function install_ccache { + if [[ $(type -P ccache) ]]; then + return + fi mkdir -p $PWD/ccache if [ -e /parent-home ]; then ln -s $PWD/ccache /parent-home/.ccache fi - ln -s $PWD/ccache $HOME/.ccache + if [ ! -e $HOME/.ccache ]; then + ln -s $PWD/ccache $HOME/.ccache + fi group_start "Install ccache" if [ -n "$IS_MACOS" ]; then @@ -104,6 +118,9 @@ function install_ccache { } function install_sccache { + if [[ $(type -P sccache) ]]; then + return + fi group_start "Install sccache" if [ -n "$IS_MACOS" ]; then brew install sccache @@ -174,10 +191,6 @@ function build_aom { local cmake_flags=() - if [ -n "$IS_MACOS" ]; then - brew remove --ignore-dependencies aom php imagemagick libavif libheif gd composer - fi - fetch_unpack \ https://storage.googleapis.com/aom-releases/libaom-$AOM_VERSION.tar.gz @@ -205,10 +218,6 @@ function build_aom { extra_cmake_flags+=("-DCMAKE_EXE_LINKER_FLAGS=-Wl,-z,stack-size=2097152") fi - # Fix for https://github.com/AOMediaCodec/libavif/issues/1190 - (cd libaom-$AOM_VERSION \ - && patch -p1 -i $CONFIG_DIR/aom-3.5.0-monochrome-realtime-encode.patch) - mkdir libaom-$AOM_VERSION/build/work (cd libaom-$AOM_VERSION/build/work \ && cmake \ @@ -224,6 +233,9 @@ function build_aom { "${cmake_flags[@]}" \ ../.. \ && make install) + + require_package aom + group_end touch aom-stamp } @@ -310,6 +322,8 @@ function build_svt_av1 { && make install \ && cp SvtAv1Enc.pc $BUILD_PREFIX/lib/pkgconfig) + require_package SvtAv1Enc + group_end touch svt-av1-stamp @@ -341,6 +355,8 @@ function build_rav1e { rm -rf $BUILD_PREFIX/lib/librav1e*.dylib fi + require_package rav1e + group_end } @@ -366,6 +382,7 @@ function build_libsharpyuv { -DBUILD_SHARED_LIBS=OFF \ "${cmake_flags[@]}" \ && ninja sharpyuv) + group_end touch libsharpyuv-stamp } @@ -390,10 +407,12 @@ function build_libyuv { fi (cd libyuv-$LIBYUV_SHA/build \ && cmake -G Ninja .. \ - -DBUILD_SHARED_LIBS=0 \ + -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ "${cmake_flags[@]}" .. \ && ninja yuv) + group_end touch libyuv-stamp } @@ -401,6 +420,10 @@ function build_libyuv { function build_libavif { LIBAVIF_CMAKE_FLAGS=() + if [ -n "$IS_MACOS" ]; then + brew remove --ignore-dependencies webp jpeg-xl aom composer gd imagemagick libavif libheif php + fi + build_aom LIBAVIF_CMAKE_FLAGS+=(-DAVIF_CODEC_AOM=ON) @@ -449,6 +472,9 @@ function build_libavif { group_end + (cd libavif-$LIBAVIF_VERSION \ + && patch -p1 -i $CONFIG_DIR/libavif-1.0.1-local-static.patch) + build_libsharpyuv mv libwebp-$LIBWEBP_SHA libavif-$LIBAVIF_VERSION/ext/libwebp LIBAVIF_CMAKE_FLAGS+=(-DAVIF_LOCAL_LIBSHARPYUV=ON) @@ -465,6 +491,7 @@ function build_libavif { && cmake .. \ -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ "${LIBAVIF_CMAKE_FLAGS[@]}" \ && make install) diff --git a/wheelbuild/libavif-1.0.1-local-static.patch b/wheelbuild/libavif-1.0.1-local-static.patch new file mode 100644 index 0000000..e7faeed --- /dev/null +++ b/wheelbuild/libavif-1.0.1-local-static.patch @@ -0,0 +1,148 @@ +From f8f4ed7ecec80a596f60a4a7e1392c09cedbf7ed Mon Sep 17 00:00:00 2001 +From: Frankie Dintino +Date: Tue, 12 Sep 2023 05:47:43 -0400 +Subject: [PATCH] ci: link shared library build against static local + +--- + CMakeLists.txt | 33 +++++++++++++-------------------- + ext/libyuv.cmd | 2 +- + 2 files changed, 14 insertions(+), 21 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1f0cde1..521560e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -78,10 +78,10 @@ endif() + + if(BUILD_SHARED_LIBS) + set(AVIF_LIBRARY_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}") +- set(AVIF_LIBRARY_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}") + else() + set(AVIF_LIBRARY_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}") +- set(AVIF_LIBRARY_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}") ++ # This is needed to get shared libraries (e.g. pixbufloader-avif) to compile against a static libavif. ++ set(CMAKE_POSITION_INDEPENDENT_CODE ON) + endif() + + set(AVIF_PLATFORM_DEFINITIONS) +@@ -112,7 +112,7 @@ if(AVIF_LOCAL_ZLIBPNG) + set(PREV_ANDROID ${ANDROID}) + set(ANDROID TRUE) + set(PNG_BUILD_ZLIB "${CMAKE_CURRENT_SOURCE_DIR}/ext/zlib" CACHE STRING "" FORCE) +- set(PNG_SHARED ${BUILD_SHARED_LIBS} CACHE BOOL "") ++ set(PNG_SHARED OFF CACHE BOOL "") + set(PNG_TESTS OFF CACHE BOOL "") + add_subdirectory(ext/libpng) + set(PNG_PNG_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/libpng") +@@ -135,7 +135,7 @@ if(AVIF_LOCAL_JPEG) + endif() + option(AVIF_LOCAL_LIBYUV "Build libyuv by providing your own copy inside the ext subdir." OFF) + if(AVIF_LOCAL_LIBYUV) +- set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/libyuv/build/${AVIF_LIBRARY_PREFIX}yuv${AVIF_LIBRARY_SUFFIX}") ++ set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/libyuv/build/${AVIF_LIBRARY_PREFIX}yuv${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(NOT EXISTS "${LIB_FILENAME}") + message(FATAL_ERROR "libavif(AVIF_LOCAL_LIBYUV): ${LIB_FILENAME} is missing, bailing out") + endif() +@@ -146,13 +146,6 @@ if(AVIF_LOCAL_LIBYUV) + set(LIBYUV_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/libyuv/include" PARENT_SCOPE) + set(LIBYUV_LIBRARY ${LIB_FILENAME} PARENT_SCOPE) + endif() +- if(BUILD_SHARED_LIBS) +- # Fix "libyuv.so: undefined reference to `jpeg_read_raw_data'" errors. +- if(NOT AVIF_LOCAL_JPEG) +- find_package(JPEG REQUIRED) +- endif() +- set(LIBYUV_LIBRARY ${LIBYUV_LIBRARY} ${JPEG_LIBRARY}) +- endif() + set(libyuv_FOUND TRUE) + message(STATUS "libavif: local libyuv found; libyuv-based fast paths enabled.") + else(AVIF_LOCAL_LIBYUV) +@@ -184,7 +177,7 @@ if(libyuv_FOUND) + endif(libyuv_FOUND) + option(AVIF_LOCAL_LIBSHARPYUV "Build libsharpyuv by providing your own copy inside the ext subdir." OFF) + if(AVIF_LOCAL_LIBSHARPYUV) +- set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/libwebp/build/libsharpyuv${AVIF_LIBRARY_SUFFIX}") ++ set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/libwebp/build/libsharpyuv${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(NOT EXISTS "${LIB_FILENAME}") + message(FATAL_ERROR "libavif(AVIF_LOCAL_LIBSHARPYUV): ${LIB_FILENAME} is missing, bailing out") + endif() +@@ -309,16 +302,16 @@ if(AVIF_CODEC_DAV1D) + if(DEFINED ANDROID_ABI) + set(AVIF_DAV1D_BUILD_DIR "${AVIF_DAV1D_BUILD_DIR}/${ANDROID_ABI}") + endif() +- set(LIB_FILENAME "${AVIF_DAV1D_BUILD_DIR}/src/libdav1d${AVIF_LIBRARY_SUFFIX}") ++ set(LIB_FILENAME "${AVIF_DAV1D_BUILD_DIR}/src/libdav1d${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(NOT EXISTS "${LIB_FILENAME}") +- if("${AVIF_LIBRARY_SUFFIX}" STREQUAL ".a") ++ if("${CMAKE_STATIC_LIBRARY_SUFFIX}" STREQUAL ".a") + message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out") + else() + # On windows, meson will produce a libdav1d.a instead of the expected libdav1d.dll/.lib. + # See https://github.com/mesonbuild/meson/issues/8153. + set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/dav1d/build/src/libdav1d.a") + if(NOT EXISTS "${LIB_FILENAME}") +- message(FATAL_ERROR "libavif: ${LIB_FILENAME} (or libdav1d${AVIF_LIBRARY_SUFFIX}) is missing, bailing out") ++ message(FATAL_ERROR "libavif: ${LIB_FILENAME} (or libdav1d${CMAKE_STATIC_LIBRARY_SUFFIX}) is missing, bailing out") + endif() + endif() + endif() +@@ -353,7 +346,7 @@ if(AVIF_CODEC_LIBGAV1) + if(DEFINED ANDROID_ABI) + set(AVIF_LIBGAV1_BUILD_DIR "${AVIF_LIBGAV1_BUILD_DIR}/${ANDROID_ABI}") + endif() +- set(LIB_FILENAME "${AVIF_LIBGAV1_BUILD_DIR}/libgav1${AVIF_LIBRARY_SUFFIX}") ++ set(LIB_FILENAME "${AVIF_LIBGAV1_BUILD_DIR}/libgav1${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(NOT EXISTS "${LIB_FILENAME}") + message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out") + endif() +@@ -378,7 +371,7 @@ if(AVIF_CODEC_RAV1E) + + if(AVIF_LOCAL_RAV1E) + set(LIB_FILENAME +- "${CMAKE_CURRENT_SOURCE_DIR}/ext/rav1e/build.libavif/usr/lib/${AVIF_LIBRARY_PREFIX}rav1e${AVIF_LIBRARY_SUFFIX}" ++ "${CMAKE_CURRENT_SOURCE_DIR}/ext/rav1e/build.libavif/usr/lib/${AVIF_LIBRARY_PREFIX}rav1e${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + if(NOT EXISTS "${LIB_FILENAME}") + message(FATAL_ERROR "libavif: compiled rav1e library is missing (in ext/rav1e/build.libavif/usr/lib), bailing out") +@@ -411,7 +404,7 @@ if(AVIF_CODEC_SVT) + + if(AVIF_LOCAL_SVT) + set(LIB_FILENAME +- "${CMAKE_CURRENT_SOURCE_DIR}/ext/SVT-AV1/Bin/Release/${AVIF_LIBRARY_PREFIX}SvtAv1Enc${AVIF_LIBRARY_SUFFIX}" ++ "${CMAKE_CURRENT_SOURCE_DIR}/ext/SVT-AV1/Bin/Release/${AVIF_LIBRARY_PREFIX}SvtAv1Enc${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + if(NOT EXISTS "${LIB_FILENAME}") + message(FATAL_ERROR "libavif: compiled svt library is missing (in ext/SVT-AV1/Bin/Release), bailing out") +@@ -450,7 +443,7 @@ if(AVIF_CODEC_AOM) + endif() + set(AVIF_SRCS ${AVIF_SRCS} src/codec_aom.c) + if(AVIF_LOCAL_AOM) +- set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/aom/build.libavif/${AVIF_LIBRARY_PREFIX}aom${AVIF_LIBRARY_SUFFIX}") ++ set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/aom/build.libavif/${AVIF_LIBRARY_PREFIX}aom${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(NOT EXISTS "${LIB_FILENAME}") + message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out") + endif() +@@ -482,7 +475,7 @@ if(AVIF_CODEC_AVM) + set(AVIF_SRCS ${AVIF_SRCS} src/codec_avm.c) + if(AVIF_LOCAL_AVM) + # Building the avm repository generates files such as "libaom.a" because it is a fork of aom. +- set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/avm/build.libavif/${AVIF_LIBRARY_PREFIX}aom${AVIF_LIBRARY_SUFFIX}") ++ set(LIB_FILENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/avm/build.libavif/${AVIF_LIBRARY_PREFIX}aom${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(NOT EXISTS "${LIB_FILENAME}") + message(FATAL_ERROR "libavif: ${LIB_FILENAME} (from avm) is missing, bailing out") + endif() +diff --git a/ext/libyuv.cmd b/ext/libyuv.cmd +index c959777..1186156 100755 +--- a/ext/libyuv.cmd ++++ b/ext/libyuv.cmd +@@ -22,6 +22,6 @@ git checkout 464c51a0 + mkdir build + cd build + +-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. ++cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF .. + ninja yuv + cd ../.. +-- +2.30.0 + diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 934c843..5bbbe21 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -147,9 +147,9 @@ def cmd_cmake(params=None, file="."): "libs": [r"libpng16.lib"], }, "libavif": { - "url": "https://github.com/AOMediaCodec/libavif/archive/v0.11.0.tar.gz", - "filename": "libavif-0.11.0.tar.gz", - "dir": "libavif-0.11.0", + "url": "https://github.com/AOMediaCodec/libavif/archive/v1.0.1.tar.gz", + "filename": "libavif-1.0.1.tar.gz", + "dir": "libavif-1.0.1", "patch": { "src/codec_aom.c": { "if (aomCpuUsed >= 7)": "if (0)",