From 8b4e66e10af3f97596caadf430c923d82ad5d36f Mon Sep 17 00:00:00 2001 From: Frankie Dintino Date: Tue, 1 Apr 2025 15:31:35 -0400 Subject: [PATCH] fix(avif): use only aomenc and dav1d to reduce wheel size Also build libavif as a shared library. When it is built as a static library, the dependency library files are combined into a single archive. But when they are linked as a shared library, the linker is able to remove unused objects. This yields a modest but not insignificant file size reduction. --- .github/workflows/wheels-dependencies.sh | 8 +++++--- wheels/dependency_licenses/RAV1E.txt | 25 ----------------------- wheels/dependency_licenses/SVT-AV1.txt | 26 ------------------------ winbuild/build_prepare.py | 4 ++-- 4 files changed, 7 insertions(+), 56 deletions(-) delete mode 100644 wheels/dependency_licenses/RAV1E.txt delete mode 100644 wheels/dependency_licenses/SVT-AV1.txt diff --git a/.github/workflows/wheels-dependencies.sh b/.github/workflows/wheels-dependencies.sh index accd99901..d841e389d 100755 --- a/.github/workflows/wheels-dependencies.sh +++ b/.github/workflows/wheels-dependencies.sh @@ -137,14 +137,16 @@ function build_libavif { && CMAKE_POLICY_VERSION_MINIMUM=3.5 cmake \ -DCMAKE_INSTALL_PREFIX=$BUILD_PREFIX \ -DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib \ + -DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib \ + -DCMAKE_MACOSX_RPATH=OFF \ -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF \ + -DBUILD_SHARED_LIBS=ON \ -DAVIF_LIBSHARPYUV=LOCAL \ -DAVIF_LIBYUV=LOCAL \ -DAVIF_CODEC_AOM=LOCAL \ + -DCONFIG_AV1_DECODER=0 \ + -DAVIF_CODEC_AOM_DECODE=OFF \ -DAVIF_CODEC_DAV1D=LOCAL \ - -DAVIF_CODEC_RAV1E=LOCAL \ - -DAVIF_CODEC_SVT=LOCAL \ -DENABLE_NASM=ON \ -DCMAKE_MODULE_PATH=/tmp/cmake/Modules \ . \ diff --git a/wheels/dependency_licenses/RAV1E.txt b/wheels/dependency_licenses/RAV1E.txt deleted file mode 100644 index 3d6c825c4..000000000 --- a/wheels/dependency_licenses/RAV1E.txt +++ /dev/null @@ -1,25 +0,0 @@ -BSD 2-Clause License - -Copyright (c) 2017-2023, the rav1e contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/wheels/dependency_licenses/SVT-AV1.txt b/wheels/dependency_licenses/SVT-AV1.txt deleted file mode 100644 index 532a982b3..000000000 --- a/wheels/dependency_licenses/SVT-AV1.txt +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2019, Alliance for Open Media. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index e118cd994..c487d4dd3 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -392,9 +392,9 @@ DEPS: dict[str, dict[str, Any]] = { "-DAVIF_LIBSHARPYUV=LOCAL", "-DAVIF_LIBYUV=LOCAL", "-DAVIF_CODEC_AOM=LOCAL", + "-DCONFIG_AV1_DECODER=0", + "-DAVIF_CODEC_AOM_DECODE=OFF", "-DAVIF_CODEC_DAV1D=LOCAL", - "-DAVIF_CODEC_RAV1E=LOCAL", - "-DAVIF_CODEC_SVT=LOCAL", "-DCMAKE_POLICY_VERSION_MINIMUM=3.5", ), cmd_xcopy("include", "{inc_dir}"),