Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AVIF plugin (decoder + encoder using libavif) #5201

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3878b58
Add AVIF plugin (using libavif)
fdintino Jan 3, 2021
e2add24
Added type hints (#2)
radarhere Oct 16, 2024
e5494a2
Fix PLAT envvar in cibuildwheel container
fdintino Oct 16, 2024
8b8bbba
Update Tests/check_avif_leaks.py
fdintino Oct 18, 2024
58ef692
Simplified code (#3)
radarhere Oct 19, 2024
d6a0a15
Merge branch 'main' into libavif-plugin
radarhere Nov 8, 2024
50b993a
Set default max threads in Python (#4)
radarhere Nov 11, 2024
671e3c8
Removed unused upsampling setting (#5)
radarhere Nov 12, 2024
658cdf3
Merge branch 'main' into libavif-plugin
radarhere Nov 18, 2024
7225cb9
Merge branch 'main' into libavif-plugin
radarhere Nov 24, 2024
3730bf2
Merge branch 'main' into libavif-plugin
radarhere Nov 30, 2024
c40bcbf
Improved error handling
radarhere Dec 2, 2024
d76ae2f
Do not ignore SyntaxError when saving EXIF data (#8)
radarhere Dec 7, 2024
9ad8311
Allow libavif to install rav1e, except on manylinux2014 and aarch64 (#7)
radarhere Dec 7, 2024
de4c6c1
Removed ld64 flag (#6)
radarhere Dec 7, 2024
524d802
fix: set exif orientation from irot/imir when decoding AVIF
fdintino Dec 9, 2024
7b73d77
Merge branch 'main' into libavif-plugin
radarhere Dec 13, 2024
a56acd8
Removed unittest mock (#10)
radarhere Dec 13, 2024
f5dc957
Use cmds_cmake (#9)
radarhere Dec 13, 2024
8d77678
chore(docs): update quality and speed with correct defaults
fdintino Dec 13, 2024
4eaa6b7
Merge branch 'main' into libavif-plugin
radarhere Dec 14, 2024
bdb24f9
Removed `_avif.HAVE_AVIF` and `_avif.VERSION` (#11)
radarhere Dec 15, 2024
ddc8e7e
Use "rav1e" if available as default ("auto") avif encoder
fdintino Dec 15, 2024
b585f9e
Simplified EXIF code (#12)
radarhere Dec 15, 2024
da2e18d
Revert "Use "rav1e" if available as default ("auto") avif encoder"
fdintino Dec 17, 2024
9b6e575
Merge branch 'main' into libavif-plugin
radarhere Dec 18, 2024
3a9a3ab
Reduced epsilons (#13)
radarhere Dec 24, 2024
9328932
Removed avifEncOptions (#14)
radarhere Jan 3, 2025
be02830
Merge branch 'main' into libavif-plugin
radarhere Jan 3, 2025
4135664
Merge branch 'main' into libavif-plugin
radarhere Jan 4, 2025
29c158d
Merge branch 'main' into libavif-plugin
radarhere Jan 8, 2025
4c63ea6
Fixed series of tuples as advanced argument (#15)
radarhere Jan 15, 2025
ce6bf21
Merge branch 'main' into libavif-plugin
radarhere Jan 17, 2025
4b29af4
Skip building libavif on 32-bit Windows (#16)
radarhere Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow libavif to install rav1e, except on manylinux2014 and aarch64 (#7)
* Allow libavif to install rav1e, except on manylinux2014 and aarch64

* Allow libavif to install rav1e on Windows

---------

Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
  • Loading branch information
radarhere and radarhere authored Dec 7, 2024
commit 9ad83119cfd0685559b722c0ebc343217d6e854f
4 changes: 0 additions & 4 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
@@ -139,10 +139,6 @@ jobs:
if: steps.build-cache.outputs.cache-hit != 'true'
run: "& winbuild\\build\\build_dep_libpng.cmd"

- name: Build dependencies / rav1e
if: steps.build-cache.outputs.cache-hit != 'true'
run: "& winbuild\\build\\build_dep_rav1e.cmd"

- name: Build dependencies / meson
if: steps.build-cache.outputs.cache-hit != 'true'
run: "& winbuild\\build\\install_meson.cmd"
67 changes: 34 additions & 33 deletions .github/workflows/wheels-dependencies.sh
Original file line number Diff line number Diff line change
@@ -97,48 +97,49 @@ function build_harfbuzz {
touch harfbuzz-stamp
}

function install_rav1e {
if [ -n "$IS_MACOS" ]; then
suffix="macos"
if [[ "$PLAT" == "arm64" ]]; then
suffix+="-aarch64"
fi
else
suffix="linux"
function build_libavif {
if [ -e libavif-stamp ]; then return; fi

if [[ -z "$IS_MACOS" ]] && ([[ "$MB_ML_VER" == 2014 ]] || [[ "$PLAT" == "aarch64" ]]); then
# Once Amazon 2 is EOL on 30 June 2025, manylinux2014 will no longer be needed
# Once GitHub Actions supports aarch64 without emulation, this will no longer needed as building will be faster
if [[ "$PLAT" == "aarch64" ]]; then
suffix+="-aarch64"
suffix="aarch64"
else
suffix+="-generic"
suffix="generic"
fi
fi

curl -sLo - \
https://github.com/xiph/rav1e/releases/download/v$RAV1E_VERSION/librav1e-$RAV1E_VERSION-$suffix.tar.gz \
| tar -C $BUILD_PREFIX --exclude LICENSE --exclude '*.so' --exclude '*.dylib' -zxf -
curl -sLo - \
https://github.com/xiph/rav1e/releases/download/v$RAV1E_VERSION/librav1e-$RAV1E_VERSION-linux-$suffix.tar.gz \
| tar -C $BUILD_PREFIX -zxf -

# Force libavif to treat system rav1e as if it were local
mkdir -p /tmp/cmake/Modules
cat <<EOF > /tmp/cmake/Modules/Findrav1e.cmake
add_library(rav1e::rav1e STATIC IMPORTED GLOBAL)
set_target_properties(rav1e::rav1e PROPERTIES
IMPORTED_LOCATION "$BUILD_PREFIX/lib/librav1e.a"
AVIF_LOCAL ON
INTERFACE_INCLUDE_DIRECTORIES "$BUILD_PREFIX/include/rav1e"
)
EOF

if [ -z "$IS_MACOS" ]; then
sed -i 's/-lgcc_s/-lgcc_eh/g' "${BUILD_PREFIX}/lib/pkgconfig/rav1e.pc"
fi
rav1e=SYSTEM
else
curl https://sh.rustup.rs -sSf | sh -s -- -y
. "$HOME/.cargo/env"

# Force libavif to treat system rav1e as if it were local
mkdir -p /tmp/cmake/Modules
cat <<EOF > /tmp/cmake/Modules/Findrav1e.cmake
add_library(rav1e::rav1e STATIC IMPORTED GLOBAL)
set_target_properties(rav1e::rav1e PROPERTIES
IMPORTED_LOCATION "$BUILD_PREFIX/lib/librav1e.a"
AVIF_LOCAL ON
INTERFACE_INCLUDE_DIRECTORIES "$BUILD_PREFIX/include/rav1e"
)
EOF
}
if [ -z "$IS_ALPINE" ] && [ -z "$IS_MACOS" ]; then
yum install -y perl
fi

rav1e=LOCAL
fi

function build_libavif {
if [ -e libavif-stamp ]; then return; fi
install_rav1e
python3 -m pip install meson ninja

if [[ "$PLAT" == "x86_64" ]]; then
build_simple nasm 2.16.03 https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/
build_simple nasm 2.16.03 https://www.nasm.us/pub/nasm/releasebuilds/2.16.03
fi

local out_dir=$(fetch_unpack https://github.com/AOMediaCodec/libavif/archive/refs/tags/v$LIBAVIF_VERSION.tar.gz libavif-$LIBAVIF_VERSION.tar.gz)
@@ -150,7 +151,7 @@ function build_libavif {
-DBUILD_SHARED_LIBS=OFF \
-DAVIF_LIBSHARPYUV=LOCAL \
-DAVIF_LIBYUV=LOCAL \
-DAVIF_CODEC_RAV1E=SYSTEM \
-DAVIF_CODEC_RAV1E=$rav1e \
-DAVIF_CODEC_AOM=LOCAL \
-DAVIF_CODEC_DAV1D=LOCAL \
-DAVIF_CODEC_SVT=LOCAL \
2 changes: 1 addition & 1 deletion docs/installation/building-from-source.rst
Original file line number Diff line number Diff line change
@@ -226,7 +226,7 @@ Many of Pillow's features require external libraries:

sudo pkg install jpeg-turbo tiff webp lcms2 freetype2 openjpeg harfbuzz fribidi libxcb libavif

See ``depends/install_raqm_cmake.sh`` to install libraqm.
Then see ``depends/install_raqm_cmake.sh`` to install libraqm.

.. tab:: Android

10 changes: 0 additions & 10 deletions winbuild/Findrav1e.cmake

This file was deleted.

19 changes: 2 additions & 17 deletions winbuild/build_prepare.py
Original file line number Diff line number Diff line change
@@ -124,7 +124,6 @@ def cmd_msbuild(
"ZLIB": "1.3.1",
"MESON": "1.6.0",
"LIBAVIF": "1.1.1",
"RAV1E": "0.7.1",
}
V["LIBPNG_DOTLESS"] = V["LIBPNG"].replace(".", "")
V["LIBPNG_XY"] = "".join(V["LIBPNG"].split(".")[:2])
@@ -400,19 +399,6 @@ def cmd_msbuild(
],
"bins": [r"*.dll"],
},
"rav1e": {
"url": (
f"https://github.com/xiph/rav1e/releases/download/v{V['RAV1E']}/FILENAME"
),
"filename": f"rav1e-{V['RAV1E']}-windows-msvc-generic.zip",
"dir": "rav1e-windows-msvc-sdk",
"license": "LICENSE",
"build": [
cmd_xcopy("include", "{inc_dir}"),
],
"bins": [r"bin\*.dll"],
"libs": [r"lib\*.*"],
},
"libavif": {
"url": f"https://github.com/AOMediaCodec/libavif/archive/v{V['LIBAVIF']}.zip",
"filename": f"libavif-{V['LIBAVIF']}.zip",
@@ -435,8 +421,7 @@ def cmd_msbuild(
"-DAVIF_CODEC_AOM=LOCAL",
"-DAVIF_LIBYUV=LOCAL",
"-DAVIF_LIBSHARPYUV=LOCAL",
"-DAVIF_CODEC_RAV1E=SYSTEM",
"-DAVIF_RAV1E_ROOT={build_dir}",
"-DAVIF_CODEC_RAV1E=LOCAL",
"-DCMAKE_MODULE_PATH={winbuild_dir_cmake}",
"-DAVIF_CODEC_DAV1D=LOCAL",
"-DAVIF_CODEC_SVT=LOCAL",
@@ -804,7 +789,7 @@ def main() -> None:
if args.no_fribidi:
disabled += ["fribidi"]
if args.no_avif or args.architecture != "AMD64":
disabled += ["rav1e", "libavif"]
disabled += ["libavif"]

prefs = {
"architecture": args.architecture,