From 870c155f9841b05968b859f0f2b004c0d5428123 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Sun, 11 Sep 2022 14:08:49 +0300 Subject: [PATCH] libheif -> `1.13.0` #38 --- .github/workflows/create-release-draft.yml | 153 +++++++++++- .github/workflows/test-src-build-windows.yml | 2 +- ...01-aom-remove-extend_padding_to_size.patch | 40 ++++ .../libheif/010-fix-loading-alpha-image.patch | 65 ------ .../libheif/011-fix-loading-alpha-image.patch | 57 ----- .../012-fix-do-not-pad-16x16-AOM.patch | 43 ---- .../libheif/013-fix-enable-lossless-AOM.patch | 49 ---- .../libheif/014-fix-RGB-to-YCbCr-chroma.patch | 217 ------------------ .../015-fix-RRGGBB-to-YCbCr-chroma.patch | 40 ---- .../016-fix-RGB-to-YCbCr-chroma-2.patch | 42 ---- .../017-fix-aom-signal-chroma-position.patch | 91 -------- .../018-expose-aom-decoder-errors.patch | 31 --- libheif/linux/libheif/019-aom-all-intra.patch | 33 --- .../libheif/020-fix-scaling-of-images.patch | 95 -------- .../021-fix-clap-box-dimensions-1.diff | 19 -- .../022-fix-clap-box-dimensions-2.patch | 24 -- .../023-fix-clap-box-dimensions-3.patch | 80 ------- .../libheif/024-fix-avif-left-shift-ub.patch | 23 -- ...025-fix-bitstream-potential-overflow.patch | 23 -- .../026-fix-encoder-no-SPS-returned-1.patch | 25 -- .../027-fix-check-results-of-read.patch | 37 --- .../028-fix-encoder-no-SPS-returned-2.patch | 35 --- .../029-fix-nclx-avoid-division-by-zero.patch | 24 -- .../libheif/030-fix-wrong-copy-size.patch | 23 -- libheif/linux_build_libs.py | 32 +-- libheif/linux_build_tools.py | 5 +- libheif/macos/libheif.rb | 139 +---------- ...001-fix-pkgconfig-provide-includedir.patch | 29 --- .../002-cmake-enable-gdk-pixbuf.patch | 25 -- libheif/windows/mingw-w64-libheif/PKGBUILD | 96 +------- pi-heif/README.md | 4 + 31 files changed, 216 insertions(+), 1385 deletions(-) create mode 100644 libheif/linux/libheif/001-aom-remove-extend_padding_to_size.patch delete mode 100644 libheif/linux/libheif/010-fix-loading-alpha-image.patch delete mode 100644 libheif/linux/libheif/011-fix-loading-alpha-image.patch delete mode 100644 libheif/linux/libheif/012-fix-do-not-pad-16x16-AOM.patch delete mode 100644 libheif/linux/libheif/013-fix-enable-lossless-AOM.patch delete mode 100644 libheif/linux/libheif/014-fix-RGB-to-YCbCr-chroma.patch delete mode 100644 libheif/linux/libheif/015-fix-RRGGBB-to-YCbCr-chroma.patch delete mode 100644 libheif/linux/libheif/016-fix-RGB-to-YCbCr-chroma-2.patch delete mode 100644 libheif/linux/libheif/017-fix-aom-signal-chroma-position.patch delete mode 100644 libheif/linux/libheif/018-expose-aom-decoder-errors.patch delete mode 100644 libheif/linux/libheif/019-aom-all-intra.patch delete mode 100644 libheif/linux/libheif/020-fix-scaling-of-images.patch delete mode 100644 libheif/linux/libheif/021-fix-clap-box-dimensions-1.diff delete mode 100644 libheif/linux/libheif/022-fix-clap-box-dimensions-2.patch delete mode 100644 libheif/linux/libheif/023-fix-clap-box-dimensions-3.patch delete mode 100644 libheif/linux/libheif/024-fix-avif-left-shift-ub.patch delete mode 100644 libheif/linux/libheif/025-fix-bitstream-potential-overflow.patch delete mode 100644 libheif/linux/libheif/026-fix-encoder-no-SPS-returned-1.patch delete mode 100644 libheif/linux/libheif/027-fix-check-results-of-read.patch delete mode 100644 libheif/linux/libheif/028-fix-encoder-no-SPS-returned-2.patch delete mode 100644 libheif/linux/libheif/029-fix-nclx-avoid-division-by-zero.patch delete mode 100644 libheif/linux/libheif/030-fix-wrong-copy-size.patch delete mode 100644 libheif/windows/mingw-w64-libheif/001-fix-pkgconfig-provide-includedir.patch delete mode 100644 libheif/windows/mingw-w64-libheif/002-cmake-enable-gdk-pixbuf.patch diff --git a/.github/workflows/create-release-draft.yml b/.github/workflows/create-release-draft.yml index 1ae3531f..d624550d 100644 --- a/.github/workflows/create-release-draft.yml +++ b/.github/workflows/create-release-draft.yml @@ -57,7 +57,7 @@ jobs: run: | cd libheif/windows/mingw-w64-libheif makepkg-mingw --syncdeps --noconfirm -f - pacman -U mingw-w64-x86_64-libheif-1.12.0-9-any.pkg.tar.zst --noconfirm + pacman -U mingw-w64-x86_64-libheif-1.13.0-2-any.pkg.tar.zst --noconfirm - name: Remove DLL trailing data run: ${{ env.MSYS2_PREFIX }}/bin/strip -s ${{ env.MSYS2_PREFIX }}/bin/*.dll @@ -68,6 +68,7 @@ jobs: CIBW_BUILD: "cp37-* cp38-* cp39-* cp310-*" CIBW_ARCHS_WINDOWS: "AMD64" CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -vv -w {dest_dir} {wheel} --add-path ${{ env.MSYS2_PREFIX }}/bin" + CIBW_ENVIRONMENT_WINDOWS: PH_FULL_ACTION=1 - name: Check built wheels run: twine check wheelhouse/* @@ -93,6 +94,7 @@ jobs: CIBW_BUILD: "*-macosx_x86_64" CIBW_SKIP: "cp36-* pp39-*" CIBW_TEST_SKIP: "cp311-*" + CIBW_ENVIRONMENT_MACOS: PH_FULL_ACTION=1 - name: Check built wheels run: twine check wheelhouse/* @@ -109,7 +111,7 @@ jobs: fail-fast: true matrix: cibw_buildlinux: [ manylinux, musllinux ] - cibw_arch: [ "aarch64", "i686", "x86_64" ] + cibw_arch: [ "aarch64", "x86_64" ] name: Wheels • ${{ matrix.cibw_buildlinux }} • ${{ matrix.cibw_arch }} • CPython runs-on: ubuntu-20.04 env: @@ -162,7 +164,80 @@ jobs: CIBW_BUILD: ${{ format('cp3*-{0}_{1}', matrix.cibw_buildlinux, matrix.cibw_arch) }} CIBW_ARCHS: ${{ matrix.cibw_arch }} CIBW_BEFORE_ALL_LINUX: ${{ env.INSTALL_OS_PACKAGES }} - CIBW_ENVIRONMENT_LINUX: BUILD_DIR_PREFIX=/host${{ env.BUILD_DIR_PREFIX }} + CIBW_ENVIRONMENT_LINUX: BUILD_DIR_PREFIX=/host${{ env.BUILD_DIR_PREFIX }} PH_FULL_ACTION=1 + + - name: Checking built wheels + run: twine check wheelhouse/* + + - name: Uploading wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: wheelhouse/*.whl + if-no-files-found: error + + - name: Fix cache permissions + run: sudo chmod -R 777 ${{ env.BUILD_DIR_PREFIX }} + + wheels_linux_cpython_32bit: + strategy: + fail-fast: true + matrix: + cibw_buildlinux: [ manylinux, musllinux ] + cibw_arch: [ "i686" ] + name: Wheels • ${{ matrix.cibw_buildlinux }} • ${{ matrix.cibw_arch }} • CPython + runs-on: ubuntu-20.04 + env: + BUILD_DIR_PREFIX: "/tmp/pillow_heif" + KEY_HEAD: ${{ matrix.cibw_arch }}-${{ matrix.cibw_buildlinux }} + + steps: + - uses: actions/checkout@v3 + - name: Set up QEMU + if: matrix.cibw_arch == 'aarch64' + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + + - name: Install cibuildwheel & twine + run: python3 -m pip install cibuildwheel twine + + - name: manylinux preparations + if: matrix.cibw_buildlinux == 'manylinux' + run: echo INSTALL_OS_PACKAGES="yum makecache && yum install -y $OS_PACKAGES" >> $GITHUB_ENV + env: + OS_PACKAGES: "git-all libjpeg-turbo-devel lcms2-devel libffi-devel" + + - name: musllinux preparations + if: matrix.cibw_buildlinux == 'musllinux' + run: echo INSTALL_OS_PACKAGES="apk update && apk --no-cache add $OS_PACKAGES" >> $GITHUB_ENV + env: + OS_PACKAGES: "sudo py3-pip python3-dev fribidi-dev harfbuzz-dev jpeg-dev lcms2-dev openjpeg-dev" + + - name: Only minimal testing on aarch64 + if: matrix.cibw_arch == 'aarch64' + run: echo CIBW_TEST_EXTRAS="tests-min" >> $GITHUB_ENV + + - uses: actions/cache@v3 + with: + path: ${{ env.BUILD_DIR_PREFIX }}/build-tools + key: ${{ env.KEY_HEAD }}-${{ hashFiles('libheif/linux_build_tools.py') }} + + - uses: actions/cache@v3 + with: + path: ${{ env.BUILD_DIR_PREFIX }}/build-stuff + key: ${{ env.KEY_HEAD }}-${{ env.KEY_CFFI_BUILD }}-${{ env.KEY_LINUX_LIBS }} + env: + KEY_LINUX_LIBS: ${{ hashFiles('libheif/linux_*.py') }}-${{ hashFiles('libheif/linux/**') }} + KEY_CFFI_BUILD: ${{ hashFiles('libheif/build.py') }}-${{ hashFiles('libheif/heif.h') }} + + - name: Run cibuildwheel + run: cibuildwheel + env: + CIBW_BUILD: ${{ format('cp3*-{0}_{1}', matrix.cibw_buildlinux, matrix.cibw_arch) }} + CIBW_ARCHS: ${{ matrix.cibw_arch }} + CIBW_BEFORE_ALL_LINUX: ${{ env.INSTALL_OS_PACKAGES }} + CIBW_ENVIRONMENT_LINUX: BUILD_DIR_PREFIX=/host${{ env.BUILD_DIR_PREFIX }} PH_LIGHT_ACTION=1 - name: Checking built wheels run: twine check wheelhouse/* @@ -182,7 +257,7 @@ jobs: fail-fast: true matrix: cibw_buildlinux: [ manylinux ] - cibw_arch: [ "aarch64", "i686", "x86_64" ] + cibw_arch: [ "aarch64", "x86_64" ] cibw_build: [ "pp37", "pp38" ] name: Wheels • ${{ matrix.cibw_buildlinux }} • ${{ matrix.cibw_arch }} • ${{ matrix.cibw_build }} runs-on: ubuntu-20.04 @@ -224,7 +299,69 @@ jobs: CIBW_BUILD: ${{ format('{0}-{1}_{2}', matrix.cibw_build , matrix.cibw_buildlinux, matrix.cibw_arch) }} CIBW_ARCHS: ${{ matrix.cibw_arch }} CIBW_BEFORE_ALL_LINUX: "yum makecache && yum install -y git-all libjpeg-turbo-devel lcms2-devel libffi-devel" - CIBW_ENVIRONMENT_LINUX: BUILD_DIR_PREFIX=/host${{ env.BUILD_DIR_PREFIX }} + CIBW_ENVIRONMENT_LINUX: BUILD_DIR_PREFIX=/host${{ env.BUILD_DIR_PREFIX }} PH_FULL_ACTION=1 + + - name: Checking built wheels + run: twine check wheelhouse/* + + - name: Uploading wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: wheelhouse/*.whl + if-no-files-found: error + + - name: Fix cache permissions + run: sudo chmod -R 777 ${{ env.BUILD_DIR_PREFIX }} + + wheels_linux_pypy_32bit: + strategy: + fail-fast: true + matrix: + cibw_buildlinux: [ manylinux ] + cibw_arch: [ "i686" ] + cibw_build: [ "pp37", "pp38" ] + name: Wheels • ${{ matrix.cibw_buildlinux }} • ${{ matrix.cibw_arch }} • ${{ matrix.cibw_build }} + runs-on: ubuntu-20.04 + env: + BUILD_DIR_PREFIX: "/tmp/pillow_heif" + KEY_HEAD: ${{ matrix.cibw_arch }}-${{ matrix.cibw_buildlinux }} + + steps: + - uses: actions/checkout@v3 + - name: Set up QEMU + if: matrix.cibw_arch == 'aarch64' + uses: docker/setup-qemu-action@v2 + with: + platforms: arm64 + + - name: Install cibuildwheel & twine + run: python3 -m pip install cibuildwheel twine + + - name: Only minimal testing on aarch64 + if: matrix.cibw_arch == 'aarch64' + run: echo CIBW_TEST_EXTRAS="tests-min" >> $GITHUB_ENV + + - uses: actions/cache@v3 + with: + path: ${{ env.BUILD_DIR_PREFIX }}/build-tools + key: ${{ env.KEY_HEAD }}-${{ hashFiles('libheif/linux_build_tools.py') }} + + - uses: actions/cache@v3 + with: + path: ${{ env.BUILD_DIR_PREFIX }}/build-stuff + key: ${{ env.KEY_HEAD }}-${{ env.KEY_CFFI_BUILD }}-${{ env.KEY_LINUX_LIBS }} + env: + KEY_LINUX_LIBS: ${{ hashFiles('libheif/linux_*.py') }}-${{ hashFiles('libheif/linux/**') }} + KEY_CFFI_BUILD: ${{ hashFiles('libheif/build.py') }}-${{ hashFiles('libheif/heif.h') }} + + - name: Run cibuildwheel + run: cibuildwheel + env: + CIBW_BUILD: ${{ format('{0}-{1}_{2}', matrix.cibw_build , matrix.cibw_buildlinux, matrix.cibw_arch) }} + CIBW_ARCHS: ${{ matrix.cibw_arch }} + CIBW_BEFORE_ALL_LINUX: "yum makecache && yum install -y git-all libjpeg-turbo-devel lcms2-devel libffi-devel" + CIBW_ENVIRONMENT_LINUX: BUILD_DIR_PREFIX=/host${{ env.BUILD_DIR_PREFIX }} PH_LIGHT_ACTION=1 - name: Checking built wheels run: twine check wheelhouse/* @@ -275,7 +412,9 @@ jobs: run: python3 -c "import pillow_heif; print(pillow_heif.libheif_info())" - name: Test sdist - run: python3 -m pytest -rs + run: | + export PH_FULL_ACTION=1 + python3 -m pytest -rs - name: Upload sdist uses: actions/upload-artifact@v3 @@ -284,7 +423,7 @@ jobs: path: wheelhouse/*.tar.gz draft_release: - needs: [sdist, wheels_linux_cpython, wheels_linux_pypy, wheels_macos, wheels_windows, wheel_armv7l] + needs: [sdist, wheels_linux_cpython, wheels_linux_pypy, wheels_macos, wheels_windows, wheel_armv7l, wheels_linux_pypy_32bit, wheels_linux_cpython_32bit] runs-on: ubuntu-20.04 name: Build and create release diff --git a/.github/workflows/test-src-build-windows.yml b/.github/workflows/test-src-build-windows.yml index 7a987d85..c819593e 100644 --- a/.github/workflows/test-src-build-windows.yml +++ b/.github/workflows/test-src-build-windows.yml @@ -47,7 +47,7 @@ jobs: run: | cd libheif/windows/mingw-w64-libheif makepkg-mingw --syncdeps --noconfirm -f - pacman -U mingw-w64-x86_64-libheif-1.12.0-9-any.pkg.tar.zst --noconfirm + pacman -U mingw-w64-x86_64-libheif-1.13.0-2-any.pkg.tar.zst --noconfirm - name: Installing Pillow-Heif run: python -m pip -v install ".[dev]" diff --git a/libheif/linux/libheif/001-aom-remove-extend_padding_to_size.patch b/libheif/linux/libheif/001-aom-remove-extend_padding_to_size.patch new file mode 100644 index 00000000..249fe2b0 --- /dev/null +++ b/libheif/linux/libheif/001-aom-remove-extend_padding_to_size.patch @@ -0,0 +1,40 @@ +From a01baccaf40bafcabddba47846f5e914ca0724f6 Mon Sep 17 00:00:00 2001 +From: Dirk Farin +Date: Mon, 5 Sep 2022 14:38:53 +0200 +Subject: [PATCH] AOM encoder: remove unnecessary call to + extend_padding_to_size() (see also #365) + +--- + libheif/heif_encoder_aom.cc | 12 +----------- + 1 file changed, 1 insertion(+), 11 deletions(-) + +diff --git a/libheif/heif_encoder_aom.cc b/libheif/heif_encoder_aom.cc +index 2a035654..e5136c1e 100644 +--- a/libheif/heif_encoder_aom.cc ++++ b/libheif/heif_encoder_aom.cc +@@ -119,7 +119,7 @@ void encoder_struct_aom::add_custom_option(std::string name, std::string value) + } + #endif + +-static const char* kError_out_of_memory = "Out of memory"; ++//static const char* kError_out_of_memory = "Out of memory"; + static const char* kError_encode_frame = "Failed to encode frame"; + + static const char* kParam_min_q = "min-q"; +@@ -727,16 +727,6 @@ struct heif_error aom_encode_image(void* encoder_raw, const struct heif_image* i + + struct heif_error err; + +- bool success = image->image->extend_padding_to_size(image->image->get_width(), +- image->image->get_height()); +- if (!success) { +- err = {heif_error_Memory_allocation_error, +- heif_suberror_Unspecified, +- kError_out_of_memory}; +- return err; +- } +- +- + const int source_width = heif_image_get_width(image, heif_channel_Y); + const int source_height = heif_image_get_height(image, heif_channel_Y); + diff --git a/libheif/linux/libheif/010-fix-loading-alpha-image.patch b/libheif/linux/libheif/010-fix-loading-alpha-image.patch deleted file mode 100644 index 28d739b0..00000000 --- a/libheif/linux/libheif/010-fix-loading-alpha-image.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 4795ba10abd233024d0536096182133fa06d9c3b Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Fri, 7 May 2021 11:33:40 +0200 -Subject: [PATCH] fix loading alpha image (do not convert to RGB) #495 - ---- - libheif/heif_context.cc | 6 +++--- - libheif/heif_context.h | 6 ++++-- - 2 files changed, 7 insertions(+), 5 deletions(-) - -diff --git a/libheif/heif_context.cc b/libheif/heif_context.cc -index f208e578..2ee4635f 100644 ---- a/libheif/heif_context.cc -+++ b/libheif/heif_context.cc -@@ -1044,7 +1044,7 @@ Error HeifContext::decode_image_user(heif_item_id ID, - Error HeifContext::decode_image_planar(heif_item_id ID, - std::shared_ptr& img, - heif_colorspace out_colorspace, -- const struct heif_decoding_options* options) const -+ const struct heif_decoding_options* options, bool alphaImage) const - { - std::string image_type = m_heif_file->get_item_type(ID); - -@@ -1136,7 +1136,7 @@ Error HeifContext::decode_image_planar(heif_item_id ID, - img->get_colorspace() : - out_colorspace); - -- if (target_colorspace == heif_colorspace_YCbCr) { -+ if (!alphaImage && target_colorspace == heif_colorspace_YCbCr) { - target_colorspace = heif_colorspace_RGB; - } - -@@ -1272,7 +1272,7 @@ Error HeifContext::decode_image_planar(heif_item_id ID, - if (alpha_image) { - std::shared_ptr alpha; - Error err = decode_image_planar(alpha_image->get_id(), alpha, -- heif_colorspace_undefined); -+ heif_colorspace_undefined, nullptr, true); - if (err) { - return err; - } -diff --git a/libheif/heif_context.h b/libheif/heif_context.h -index 441435ce..503b39a7 100644 ---- a/libheif/heif_context.h -+++ b/libheif/heif_context.h -@@ -91,7 +91,8 @@ namespace heif { - - ~Image(); - -- void clear() { -+ void clear() -+ { - m_thumbnails.clear(); - m_alpha_channel.reset(); - m_depth_channel.reset(); -@@ -337,7 +338,8 @@ namespace heif { - - Error decode_image_planar(heif_item_id ID, std::shared_ptr& img, - heif_colorspace out_colorspace, -- const struct heif_decoding_options* options = nullptr) const; -+ const struct heif_decoding_options* options = nullptr, -+ bool alphaImage = false) const; - - std::string debug_dump_boxes() const; - diff --git a/libheif/linux/libheif/011-fix-loading-alpha-image.patch b/libheif/linux/libheif/011-fix-loading-alpha-image.patch deleted file mode 100644 index 79a0d616..00000000 --- a/libheif/linux/libheif/011-fix-loading-alpha-image.patch +++ /dev/null @@ -1,57 +0,0 @@ -From c32f15512323960097b99c204535ec53d11fb355 Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Fri, 7 May 2021 12:45:28 +0200 -Subject: [PATCH] don't color convert alpha images #495 - ---- - libheif/heif_context.cc | 33 +++++++++++++++++++-------------- - 1 file changed, 19 insertions(+), 14 deletions(-) - -diff --git a/libheif/heif_context.cc b/libheif/heif_context.cc -index 2ee4635f..ce4c65b1 100644 ---- a/libheif/heif_context.cc -+++ b/libheif/heif_context.cc -@@ -1132,24 +1132,29 @@ Error HeifContext::decode_image_planar(heif_item_id ID, - img->set_color_profile_icc(icc); - } - -- heif_colorspace target_colorspace = (out_colorspace == heif_colorspace_undefined ? -- img->get_colorspace() : -- out_colorspace); -- -- if (!alphaImage && target_colorspace == heif_colorspace_YCbCr) { -- target_colorspace = heif_colorspace_RGB; -+ if (alphaImage) { -+ // no color conversion required - } -+ else { -+ heif_colorspace target_colorspace = (out_colorspace == heif_colorspace_undefined ? -+ img->get_colorspace() : -+ out_colorspace); - -- heif_chroma target_chroma = (target_colorspace == heif_colorspace_monochrome ? -- heif_chroma_monochrome : heif_chroma_444); -+ if (!alphaImage && target_colorspace == heif_colorspace_YCbCr) { -+ target_colorspace = heif_colorspace_RGB; -+ } - -- bool different_chroma = (target_chroma != img->get_chroma_format()); -- bool different_colorspace = (target_colorspace != img->get_colorspace()); -+ heif_chroma target_chroma = (target_colorspace == heif_colorspace_monochrome ? -+ heif_chroma_monochrome : heif_chroma_444); - -- if (different_chroma || different_colorspace) { -- img = convert_colorspace(img, target_colorspace, target_chroma, nullptr); -- if (!img) { -- return Error(heif_error_Unsupported_feature, heif_suberror_Unsupported_color_conversion); -+ bool different_chroma = (target_chroma != img->get_chroma_format()); -+ bool different_colorspace = (target_colorspace != img->get_colorspace()); -+ -+ if (different_chroma || different_colorspace) { -+ img = convert_colorspace(img, target_colorspace, target_chroma, nullptr); -+ if (!img) { -+ return Error(heif_error_Unsupported_feature, heif_suberror_Unsupported_color_conversion); -+ } - } - } - } diff --git a/libheif/linux/libheif/012-fix-do-not-pad-16x16-AOM.patch b/libheif/linux/libheif/012-fix-do-not-pad-16x16-AOM.patch deleted file mode 100644 index b95dd374..00000000 --- a/libheif/linux/libheif/012-fix-do-not-pad-16x16-AOM.patch +++ /dev/null @@ -1,43 +0,0 @@ -From ec1dc464dc08517ecef7b675043886ec727eadb2 Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Wed, 12 May 2021 20:06:30 +0200 -Subject: [PATCH] do not pad image size to 16x16 pixels minimum for AOM encoder - ---- - libheif/heif_encoder_aom.cc | 16 ++++------------ - 1 file changed, 4 insertions(+), 12 deletions(-) - -diff --git a/libheif/heif_encoder_aom.cc b/libheif/heif_encoder_aom.cc -index 5233c411..65c92b1b 100644 ---- a/libheif/heif_encoder_aom.cc -+++ b/libheif/heif_encoder_aom.cc -@@ -530,8 +530,8 @@ void aom_query_input_colorspace2(void* encoder_raw, heif_colorspace* colorspace, - void aom_query_encoded_size(void* encoder, uint32_t input_width, uint32_t input_height, - uint32_t* encoded_width, uint32_t* encoded_height) - { -- *encoded_width = std::max(input_width, 16U); -- *encoded_height = std::max(input_height, 16U); -+ *encoded_width = input_width; -+ *encoded_height = input_height; - } - - -@@ -563,16 +563,8 @@ struct heif_error aom_encode_image(void* encoder_raw, const struct heif_image* i - - struct heif_error err; - -- // --- round image size to minimum size -- -- uint32_t rounded_width, rounded_height; -- aom_query_encoded_size(encoder, -- image->image->get_width(), -- image->image->get_height(), -- &rounded_width, -- &rounded_height); -- -- bool success = image->image->extend_padding_to_size(rounded_width, rounded_height); -+ bool success = image->image->extend_padding_to_size(image->image->get_width(), -+ image->image->get_height()); - if (!success) { - err = {heif_error_Memory_allocation_error, - heif_suberror_Unspecified, diff --git a/libheif/linux/libheif/013-fix-enable-lossless-AOM.patch b/libheif/linux/libheif/013-fix-enable-lossless-AOM.patch deleted file mode 100644 index 65a44f40..00000000 --- a/libheif/linux/libheif/013-fix-enable-lossless-AOM.patch +++ /dev/null @@ -1,49 +0,0 @@ -From b2612dd9c63f8835cf2047960b8cacd464a325a4 Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Wed, 12 May 2021 20:32:57 +0200 -Subject: [PATCH] explicitly enable lossless mode in AOM encoder - ---- - libheif/heif_encoder_aom.cc | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/libheif/heif_encoder_aom.cc b/libheif/heif_encoder_aom.cc -index 65c92b1b..65a72e29 100644 ---- a/libheif/heif_encoder_aom.cc -+++ b/libheif/heif_encoder_aom.cc -@@ -47,6 +47,7 @@ struct encoder_struct_aom - int min_q; - int max_q; - int threads; -+ bool lossless; - - aom_tune_metric tune; - -@@ -288,6 +289,8 @@ struct heif_error aom_set_parameter_lossless(void* encoder_raw, int enable) - encoder->max_q = 0; - } - -+ encoder->lossless = enable; -+ - return heif_error_ok; - } - -@@ -295,7 +298,7 @@ struct heif_error aom_get_parameter_lossless(void* encoder_raw, int* enable) - { - struct encoder_struct_aom* encoder = (struct encoder_struct_aom*) encoder_raw; - -- *enable = (encoder->min_q == 0 && encoder->max_q == 0); -+ *enable = encoder->lossless; - - return heif_error_ok; - } -@@ -768,6 +771,9 @@ struct heif_error aom_encode_image(void* encoder_raw, const struct heif_image* i - - aom_codec_control(&codec, AOME_SET_TUNING, encoder->tune); - -+ if (encoder->lossless) { -+ aom_codec_control(&codec, AV1E_SET_LOSSLESS, 1); -+ } - - // --- encode frame - diff --git a/libheif/linux/libheif/014-fix-RGB-to-YCbCr-chroma.patch b/libheif/linux/libheif/014-fix-RGB-to-YCbCr-chroma.patch deleted file mode 100644 index 4e2131c8..00000000 --- a/libheif/linux/libheif/014-fix-RGB-to-YCbCr-chroma.patch +++ /dev/null @@ -1,217 +0,0 @@ -From 2c8d963dfc0b967e6c78259ba0a99185b27206d8 Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 12 Jul 2021 14:10:20 +0200 -Subject: [PATCH] Op_RGB24_32_to_YCbCr: move chroma 4:2:0 sampling position to - center (#521) - ---- - libheif/heif_colorconversion.cc | 166 +++++++++++++++++++++++++++++--- - 1 file changed, 150 insertions(+), 16 deletions(-) - -diff --git a/libheif/heif_colorconversion.cc b/libheif/heif_colorconversion.cc -index 7e420912..8803ffc8 100644 ---- a/libheif/heif_colorconversion.cc -+++ b/libheif/heif_colorconversion.cc -@@ -34,6 +34,9 @@ using namespace heif; - #define DEBUG_ME 0 - #define DEBUG_PIPELINE_CREATION 0 - -+#define USE_CENTER_CHROMA_422 0 -+ -+ - std::ostream& operator<<(std::ostream& ostr, heif_colorspace c) - { - switch (c) { -@@ -1944,6 +1947,25 @@ static inline uint8_t clip_f_u8(float fx) - } - - -+inline void set_chroma_pixels(uint8_t* out_cb, uint8_t* out_cr, -+ uint8_t r, uint8_t g, uint8_t b, -+ const RGB_to_YCbCr_coefficients& coeffs, -+ bool full_range_flag) -+{ -+ float cb = r * coeffs.c[1][0] + g * coeffs.c[1][1] + b * coeffs.c[1][2]; -+ float cr = r * coeffs.c[2][0] + g * coeffs.c[2][1] + b * coeffs.c[2][2]; -+ -+ if (full_range_flag) { -+ *out_cb = clip_f_u8(cb + 128); -+ *out_cr = clip_f_u8(cr + 128); -+ } -+ else { -+ *out_cb = (uint8_t) clip_f_u8(cb * 0.875f + 128.0f); -+ *out_cr = (uint8_t) clip_f_u8(cr * 0.875f + 128.0f); -+ } -+} -+ -+ - std::shared_ptr - Op_RGB24_32_to_YCbCr::convert_colorspace(const std::shared_ptr& input, - ColorState target_state, -@@ -2024,30 +2046,142 @@ Op_RGB24_32_to_YCbCr::convert_colorspace(const std::shared_ptr - if (input->has_channel(channel)) { - int input_bits = input->get_bits_per_pixel(channel); - -- if (input_bits>8) { -+ if (input_bits > 8) { - int width = input->get_width(channel); - int height = input->get_height(channel); - outimg->add_plane(channel, width, height, 8); diff --git a/libheif/linux/libheif/015-fix-RRGGBB-to-YCbCr-chroma.patch b/libheif/linux/libheif/015-fix-RRGGBB-to-YCbCr-chroma.patch deleted file mode 100644 index 155b93d0..00000000 --- a/libheif/linux/libheif/015-fix-RRGGBB-to-YCbCr-chroma.patch +++ /dev/null @@ -1,40 +0,0 @@ -From ab0af732fd3c2ebf0211a0a072c76789c8d38d39 Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 12 Jul 2021 16:50:18 +0200 -Subject: [PATCH] Op_RRGGBBxx_HDR_to_YCbCr420: move chroma 4:2:0 sampling - position to center (#521) - ---- - libheif/heif_colorconversion.cc | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -diff --git a/libheif/heif_colorconversion.cc b/libheif/heif_colorconversion.cc -index 8803ffc8..92f78b4e 100644 ---- a/libheif/heif_colorconversion.cc -+++ b/libheif/heif_colorconversion.cc -@@ -2786,6 +2786,25 @@ Op_RRGGBBxx_HDR_to_YCbCr420::convert_colorspace(const std::shared_ptr((in[2 + le] << 8) | in[3 - le]); - float b = static_cast((in[4 + le] << 8) | in[5 - le]); - -+ int dx = (x + 1 < width) ? bytesPerPixel : 0; -+ int dy = (y + 1 < height) ? in_p_stride : 0; -+ -+ r += static_cast((in[0 + le + dx] << 8) | in[1 - le + dx]); -+ g += static_cast((in[2 + le + dx] << 8) | in[3 - le + dx]); -+ b += static_cast((in[4 + le + dx] << 8) | in[5 - le + dx]); -+ -+ r += static_cast((in[0 + le + dy] << 8) | in[1 - le + dy]); -+ g += static_cast((in[2 + le + dy] << 8) | in[3 - le + dy]); -+ b += static_cast((in[4 + le + dy] << 8) | in[5 - le + dy]); -+ -+ r += static_cast((in[0 + le + dx + dy] << 8) | in[1 - le + dx + dy]); -+ g += static_cast((in[2 + le + dx + dy] << 8) | in[3 - le + dx + dy]); -+ b += static_cast((in[4 + le + dx + dy] << 8) | in[5 - le + dx + dy]); -+ -+ r *= 0.25f; -+ g *= 0.25f; -+ b *= 0.25f; -+ - float cb = r * coeffs.c[1][0] + g * coeffs.c[1][1] + b * coeffs.c[1][2]; - float cr = r * coeffs.c[2][0] + g * coeffs.c[2][1] + b * coeffs.c[2][2]; - diff --git a/libheif/linux/libheif/016-fix-RGB-to-YCbCr-chroma-2.patch b/libheif/linux/libheif/016-fix-RGB-to-YCbCr-chroma-2.patch deleted file mode 100644 index e8f4975f..00000000 --- a/libheif/linux/libheif/016-fix-RGB-to-YCbCr-chroma-2.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 2dfc9b2c04ce77c0d85af37a4f66c0ee2dbe058d Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 12 Jul 2021 17:00:09 +0200 -Subject: [PATCH] Op_RGB_to_YCbCr: move chroma 4:2:0 sampling position to - center (#521) - ---- - libheif/heif_colorconversion.cc | 21 +++++++++++++++++++++ - 1 file changed, 21 insertions(+) - -diff --git a/libheif/heif_colorconversion.cc b/libheif/heif_colorconversion.cc -index 92f78b4e..f85bcccb 100644 ---- a/libheif/heif_colorconversion.cc -+++ b/libheif/heif_colorconversion.cc -@@ -723,6 +723,27 @@ Op_RGB_to_YCbCr::convert_colorspace(const std::shared_ptr 1 || subV > 1) { -+ int x2 = (x + 1 < width && subH == 2 && subV == 2) ? x + 1 : x; // subV==2 -> Do not center for 4:2:2 (see comment in Op_RGB24_32_to_YCbCr, github issue #521) -+ int y2 = (y + 1 < height && subV == 2) ? y + 1 : y; -+ -+ r += in_r[y * in_r_stride + x2]; -+ g += in_g[y * in_g_stride + x2]; -+ b += in_b[y * in_b_stride + x2]; -+ -+ r += in_r[y2 * in_r_stride + x]; -+ g += in_g[y2 * in_g_stride + x]; -+ b += in_b[y2 * in_b_stride + x]; -+ -+ r += in_r[y2 * in_r_stride + x2]; -+ g += in_g[y2 * in_g_stride + x2]; -+ b += in_b[y2 * in_b_stride + x2]; -+ -+ r *= 0.25f; -+ g *= 0.25f; -+ b *= 0.25f; -+ } -+ - float cb, cr; - - cb = r * coeffs.c[1][0] + g * coeffs.c[1][1] + b * coeffs.c[1][2]; diff --git a/libheif/linux/libheif/017-fix-aom-signal-chroma-position.patch b/libheif/linux/libheif/017-fix-aom-signal-chroma-position.patch deleted file mode 100644 index 98fadd52..00000000 --- a/libheif/linux/libheif/017-fix-aom-signal-chroma-position.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 487c3d821df79178edd18a62285449d8d1f70160 Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 12 Jul 2021 18:16:11 +0200 -Subject: [PATCH] AVIF: signal chroma sample position when encoding (#521) - ---- - libheif/heif_encoder_aom.cc | 6 ++++++ - libheif/heif_encoder_rav1e.cc | 8 ++++++-- - 2 files changed, 12 insertions(+), 2 deletions(-) - -diff --git a/libheif/heif_encoder_aom.cc b/libheif/heif_encoder_aom.cc -index 65a72e29..6bc2f25f 100644 ---- a/libheif/heif_encoder_aom.cc -+++ b/libheif/heif_encoder_aom.cc -@@ -590,23 +590,28 @@ struct heif_error aom_encode_image(void* encoder_raw, const struct heif_image* i - aom_img_fmt_t img_format = AOM_IMG_FMT_NONE; - - int chroma_height = 0; -+ int chroma_sample_position = AOM_CSP_UNKNOWN; - - switch (chroma) { - case heif_chroma_420: - case heif_chroma_monochrome: - img_format = AOM_IMG_FMT_I420; - chroma_height = (source_height+1)/2; -+ chroma_sample_position = AOM_CSP_UNKNOWN; // TODO: change this to CSP_CENTER in the future (https://github.com/AOMediaCodec/av1-avif/issues/88) - break; - case heif_chroma_422: - img_format = AOM_IMG_FMT_I422; - chroma_height = (source_height+1)/2; -+ chroma_sample_position = AOM_CSP_COLOCATED; - break; - case heif_chroma_444: - img_format = AOM_IMG_FMT_I444; - chroma_height = source_height; -+ chroma_sample_position = AOM_CSP_COLOCATED; - break; - default: - img_format = AOM_IMG_FMT_NONE; -+ chroma_sample_position = AOM_CSP_UNKNOWN; - assert(false); - break; - } -@@ -760,6 +765,7 @@ struct heif_error aom_encode_image(void* encoder_raw, const struct heif_image* i - - // In aom, color_range defaults to limited range (0). Set it to full range (1). - aom_codec_control(&codec, AV1E_SET_COLOR_RANGE, nclx ? nclx->get_full_range_flag() : 1); -+ aom_codec_control(&codec, AV1E_SET_CHROMA_SAMPLE_POSITION, chroma_sample_position); - - if (nclx && - (input_class == heif_image_input_class_normal || -diff --git a/libheif/heif_encoder_rav1e.cc b/libheif/heif_encoder_rav1e.cc -index cec32080..14ce68f1 100644 ---- a/libheif/heif_encoder_rav1e.cc -+++ b/libheif/heif_encoder_rav1e.cc -@@ -515,7 +515,9 @@ struct heif_error rav1e_encode_image(void* encoder_raw, const struct heif_image* - - uint8_t yShift = 0; - RaChromaSampling chromaSampling; -+ RaChromaSamplePosition chromaPosition; - RaPixelRange rav1eRange; -+ - if (input_class == heif_image_input_class_alpha) { - chromaSampling = RA_CHROMA_SAMPLING_CS420; // I can't seem to get RA_CHROMA_SAMPLING_CS400 to work right now, unfortunately - } -@@ -523,12 +525,15 @@ struct heif_error rav1e_encode_image(void* encoder_raw, const struct heif_image* - switch (chroma) { - case heif_chroma_444: - chromaSampling = RA_CHROMA_SAMPLING_CS444; -+ chromaPosition = RA_CHROMA_SAMPLE_POSITION_COLOCATED; - break; - case heif_chroma_422: - chromaSampling = RA_CHROMA_SAMPLING_CS422; -+ chromaPosition = RA_CHROMA_SAMPLE_POSITION_COLOCATED; - break; - case heif_chroma_420: - chromaSampling = RA_CHROMA_SAMPLING_CS420; -+ chromaPosition = RA_CHROMA_SAMPLE_POSITION_UNKNOWN; // TODO: set to CENTER when AV1 and rav1e supports this - yShift = 1; - break; - default: -@@ -548,8 +553,7 @@ struct heif_error rav1e_encode_image(void* encoder_raw, const struct heif_image* - auto rav1eConfigRaw = rav1e_config_default(); - auto rav1eConfig = std::shared_ptr(rav1eConfigRaw, [](RaConfig* c) { rav1e_config_unref(c); }); - -- if (rav1e_config_set_pixel_format(rav1eConfig.get(), (uint8_t) bitDepth, chromaSampling, -- RA_CHROMA_SAMPLE_POSITION_UNKNOWN, rav1eRange) < 0) { -+ if (rav1e_config_set_pixel_format(rav1eConfig.get(), (uint8_t) bitDepth, chromaSampling, chromaPosition, rav1eRange) < 0) { - return heif_error_codec_library_error; - } - diff --git a/libheif/linux/libheif/018-expose-aom-decoder-errors.patch b/libheif/linux/libheif/018-expose-aom-decoder-errors.patch deleted file mode 100644 index a4f25fd8..00000000 --- a/libheif/linux/libheif/018-expose-aom-decoder-errors.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 7e1c1888023f6dd68cf33e537e7eb8e4d5e17588 Mon Sep 17 00:00:00 2001 -From: Lovell Fuller -Date: Sat, 8 May 2021 10:02:18 +0100 -Subject: [PATCH] aom: expose decoder error messages - ---- - libheif/heif_decoder_aom.cc | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/libheif/heif_decoder_aom.cc b/libheif/heif_decoder_aom.cc -index aca88f60..817c5d83 100644 ---- a/libheif/heif_decoder_aom.cc -+++ b/libheif/heif_decoder_aom.cc -@@ -97,7 +97,7 @@ struct heif_error aom_new_decoder(void** dec) - - delete decoder; - -- struct heif_error err = {heif_error_Decoder_plugin_error, heif_suberror_Unspecified, kSuccess}; -+ struct heif_error err = {heif_error_Decoder_plugin_error, heif_suberror_Unspecified, aom_codec_err_to_string(aomerr)}; - return err; - } - -@@ -133,7 +133,7 @@ struct heif_error aom_push_data(void* decoder_raw, const void* frame_data, size_ - aom_codec_err_t aomerr; - aomerr = aom_codec_decode(&decoder->codec, (const uint8_t*) frame_data, frame_size, NULL); - if (aomerr) { -- struct heif_error err = {heif_error_Invalid_input, heif_suberror_Unspecified, kSuccess}; -+ struct heif_error err = {heif_error_Invalid_input, heif_suberror_Unspecified, aom_codec_err_to_string(aomerr)}; - return err; - } - diff --git a/libheif/linux/libheif/019-aom-all-intra.patch b/libheif/linux/libheif/019-aom-all-intra.patch deleted file mode 100644 index 28e22c2e..00000000 --- a/libheif/linux/libheif/019-aom-all-intra.patch +++ /dev/null @@ -1,33 +0,0 @@ -From de0c159a60c2c50931321f06e36a3b6640c5c807 Mon Sep 17 00:00:00 2001 -From: Lovell Fuller -Date: Fri, 7 May 2021 21:43:51 +0100 -Subject: [PATCH] aom encoder: improve performance by ~2x using new 'all intra' - mode - -Available from aom v3.1.0, this usage mode is considered the -default setting for still images. - -It uses a single pass and removes all keyframe logic, resulting -in significantly fewer memory allocations and halves CPU time. - -libavif has already adopted this as the default. ---- - libheif/heif_encoder_aom.cc | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/libheif/heif_encoder_aom.cc b/libheif/heif_encoder_aom.cc -index 65a72e29..460764b6 100644 ---- a/libheif/heif_encoder_aom.cc -+++ b/libheif/heif_encoder_aom.cc -@@ -691,7 +691,10 @@ struct heif_error aom_encode_image(void* encoder_raw, const struct heif_image* i - - - unsigned int aomUsage = 0; --#if defined(AOM_USAGE_REALTIME) -+#if defined(AOM_USAGE_ALL_INTRA) -+ // aom 3.1.0 -+ aomUsage = (encoder->realtime_mode ? AOM_USAGE_REALTIME : AOM_USAGE_ALL_INTRA); -+#elif defined(AOM_USAGE_REALTIME) - // aom 2.0 - aomUsage = (encoder->realtime_mode ? AOM_USAGE_REALTIME : AOM_USAGE_GOOD_QUALITY); - #endif diff --git a/libheif/linux/libheif/020-fix-scaling-of-images.patch b/libheif/linux/libheif/020-fix-scaling-of-images.patch deleted file mode 100644 index d635f3fa..00000000 --- a/libheif/linux/libheif/020-fix-scaling-of-images.patch +++ /dev/null @@ -1,95 +0,0 @@ -From 0cd461e18b99d018f9adef731eec928781078afb Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 12 Jul 2021 19:48:08 +0200 -Subject: [PATCH] Fix scaling of images. Make sure that chroma planes have - correct size when luma plane is odd. (#524) - ---- - libheif/heif_image.cc | 65 ++++++++++++++++++++++++++++++++++--------- - 1 file changed, 52 insertions(+), 13 deletions(-) - -diff --git a/libheif/heif_image.cc b/libheif/heif_image.cc -index 41d15e35..44d38e11 100644 ---- a/libheif/heif_image.cc -+++ b/libheif/heif_image.cc -@@ -892,6 +892,53 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr& ou - out_img->create(width, height, m_colorspace, m_chroma); - - -+ // --- create output image with scaled planes -+ -+ if (has_channel(heif_channel_interleaved)) { -+ out_img->add_plane(heif_channel_interleaved, width, height, get_bits_per_pixel(heif_channel_interleaved)); -+ } -+ else { -+ if (get_colorspace() == heif_colorspace_RGB) { -+ if (!has_channel(heif_channel_R) || -+ !has_channel(heif_channel_G) || -+ !has_channel(heif_channel_B)) { -+ return Error(heif_error_Invalid_input, heif_suberror_Unspecified, "RGB input without R,G,B, planes"); -+ } -+ -+ out_img->add_plane(heif_channel_R, width, height, get_bits_per_pixel(heif_channel_R)); -+ out_img->add_plane(heif_channel_G, width, height, get_bits_per_pixel(heif_channel_G)); -+ out_img->add_plane(heif_channel_B, width, height, get_bits_per_pixel(heif_channel_B)); -+ } -+ else if (get_colorspace() == heif_colorspace_monochrome) { -+ if (!has_channel(heif_channel_Y)) { -+ return Error(heif_error_Invalid_input, heif_suberror_Unspecified, "monochrome input with no Y plane"); -+ } -+ -+ out_img->add_plane(heif_channel_Y, width, height, get_bits_per_pixel(heif_channel_Y)); -+ } -+ else if (get_colorspace() == heif_colorspace_YCbCr) { -+ if (!has_channel(heif_channel_Y) || -+ !has_channel(heif_channel_Cb) || -+ !has_channel(heif_channel_Cr)) { -+ return Error(heif_error_Invalid_input, heif_suberror_Unspecified, "YCbCr image without Y,Cb,Cr planes"); -+ } -+ -+ int cw, ch; -+ get_subsampled_size(width, height, heif_channel_Cb, get_chroma_format(), &cw, &ch); -+ out_img->add_plane(heif_channel_Y, width, height, get_bits_per_pixel(heif_channel_Y)); -+ out_img->add_plane(heif_channel_Cb, cw, ch, get_bits_per_pixel(heif_channel_Cb)); -+ out_img->add_plane(heif_channel_Cr, cw, ch, get_bits_per_pixel(heif_channel_Cr)); -+ } -+ else { -+ return Error(heif_error_Invalid_input, heif_suberror_Unspecified, "unknown color configuration"); -+ } -+ -+ if (has_channel(heif_channel_Alpha)) { -+ out_img->add_plane(heif_channel_Alpha, width,height, get_bits_per_pixel(heif_channel_Alpha)); -+ } -+ } -+ -+ - // --- scale all channels - - for (const auto& plane_pair : m_planes) { -@@ -900,21 +947,13 @@ Error HeifPixelImage::scale_nearest_neighbor(std::shared_ptr& ou - - const int bpp = get_storage_bits_per_pixel(channel) / 8; - -- int in_w = plane.m_width; -- int in_h = plane.m_height; -- -- int out_w = in_w * width / m_width; -- int out_h = in_h * height / m_height; -- -- out_img->add_plane(channel, -- out_w, -- out_h, -- plane.m_bit_depth); -- -- if (!width || !height) { -- continue; -+ if (!out_img->has_channel(channel)) { -+ return Error(heif_error_Invalid_input, heif_suberror_Unspecified, "scaling input has extra color plane"); - } - -+ int out_w = out_img->get_width(channel); -+ int out_h = out_img->get_height(channel); -+ - int in_stride = plane.stride; - const uint8_t* in_data = plane.mem; - diff --git a/libheif/linux/libheif/021-fix-clap-box-dimensions-1.diff b/libheif/linux/libheif/021-fix-clap-box-dimensions-1.diff deleted file mode 100644 index 52421760..00000000 --- a/libheif/linux/libheif/021-fix-clap-box-dimensions-1.diff +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/fuzzing/corpus/clap-overflow-divide-zero.heic b/fuzzing/corpus/clap-overflow-divide-zero.heic -new file mode 100644 -index 00000000..416aff09 -Binary files /dev/null and b/fuzzing/corpus/clap-overflow-divide-zero.heic differ -diff --git a/libheif/box.cc b/libheif/box.cc -index 2420d5a4..0de1f589 100644 ---- a/libheif/box.cc -+++ b/libheif/box.cc -@@ -2306,6 +2306,10 @@ Error Box_clap::parse(BitstreamRange& range) - int32_t horizontal_offset_den = range.read32(); - int32_t vertical_offset_num = range.read32(); - int32_t vertical_offset_den = range.read32(); -+ if (clean_aperture_width_num < 0 || clean_aperture_width_den < 0 || -+ clean_aperture_height_num < 0 || clean_aperture_height_den < 0) { -+ return Error(heif_error_Invalid_input, heif_suberror_Invalid_image_size); -+ } - m_clean_aperture_width = Fraction(clean_aperture_width_num, - clean_aperture_width_den); - m_clean_aperture_height = Fraction(clean_aperture_height_num, diff --git a/libheif/linux/libheif/022-fix-clap-box-dimensions-2.patch b/libheif/linux/libheif/022-fix-clap-box-dimensions-2.patch deleted file mode 100644 index bdd8c73a..00000000 --- a/libheif/linux/libheif/022-fix-clap-box-dimensions-2.patch +++ /dev/null @@ -1,24 +0,0 @@ -From ca2473d9eca36697aa531f42209567cc663ceaee Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 12 Jul 2021 20:42:05 +0200 -Subject: [PATCH] check whether 'clap' input fraction exceeds supported range - (#504) - ---- - libheif/box.h | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/libheif/box.h b/libheif/box.h -index e5019a2b..32e49290 100644 ---- a/libheif/box.h -+++ b/libheif/box.h -@@ -69,6 +69,9 @@ namespace heif { - - Fraction(int32_t num, int32_t den); - -+ // may only use values up to int32_t maximum -+ Fraction(uint32_t num, uint32_t den); -+ - Fraction operator+(const Fraction&) const; - - Fraction operator-(const Fraction&) const; diff --git a/libheif/linux/libheif/023-fix-clap-box-dimensions-3.patch b/libheif/linux/libheif/023-fix-clap-box-dimensions-3.patch deleted file mode 100644 index e5f1c7ea..00000000 --- a/libheif/linux/libheif/023-fix-clap-box-dimensions-3.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 2c4cb5712724b5617019dc749b91b0acd0f9ad7c Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 12 Jul 2021 20:42:18 +0200 -Subject: [PATCH] check whether 'clap' input fraction exceeds supported range - (replaced fix from #504) - ---- - libheif/box.cc | 44 +++++++++++++++++++++++++++++++------------- - 1 file changed, 31 insertions(+), 13 deletions(-) - -diff --git a/libheif/box.cc b/libheif/box.cc -index 0de1f589..9a828cc9 100644 ---- a/libheif/box.cc -+++ b/libheif/box.cc -@@ -59,6 +59,14 @@ Fraction::Fraction(int32_t num, int32_t den) - } - } - -+Fraction::Fraction(uint32_t num, uint32_t den) -+{ -+ assert(num <= std::numeric_limits::max()); -+ assert(den <= std::numeric_limits::max()); -+ -+ *this = Fraction(int32_t(num), int32_t(den)); -+} -+ - Fraction Fraction::operator+(const Fraction& b) const - { - if (denominator == b.denominator) { -@@ -2298,18 +2306,28 @@ Error Box_clap::parse(BitstreamRange& range) - { - //parse_full_box_header(range); - -- int32_t clean_aperture_width_num = range.read32(); -- int32_t clean_aperture_width_den = range.read32(); -- int32_t clean_aperture_height_num = range.read32(); -- int32_t clean_aperture_height_den = range.read32(); -- int32_t horizontal_offset_num = range.read32(); -- int32_t horizontal_offset_den = range.read32(); -- int32_t vertical_offset_num = range.read32(); -- int32_t vertical_offset_den = range.read32(); -- if (clean_aperture_width_num < 0 || clean_aperture_width_den < 0 || -- clean_aperture_height_num < 0 || clean_aperture_height_den < 0) { -- return Error(heif_error_Invalid_input, heif_suberror_Invalid_image_size); -+ uint32_t clean_aperture_width_num = range.read32(); -+ uint32_t clean_aperture_width_den = range.read32(); -+ uint32_t clean_aperture_height_num = range.read32(); -+ uint32_t clean_aperture_height_den = range.read32(); -+ uint32_t horizontal_offset_num = range.read32(); -+ uint32_t horizontal_offset_den = range.read32(); -+ uint32_t vertical_offset_num = range.read32(); -+ uint32_t vertical_offset_den = range.read32(); -+ -+ if (clean_aperture_width_num > std::numeric_limits::max() || -+ clean_aperture_width_den > std::numeric_limits::max() || -+ clean_aperture_height_num > std::numeric_limits::max() || -+ clean_aperture_height_den > std::numeric_limits::max() || -+ horizontal_offset_num > std::numeric_limits::max() || -+ horizontal_offset_den > std::numeric_limits::max() || -+ vertical_offset_num > std::numeric_limits::max() || -+ vertical_offset_den > std::numeric_limits::max()) { -+ return Error(heif_error_Invalid_input, -+ heif_suberror_Invalid_fractional_number, -+ "Exceeded supported value range."); - } -+ - m_clean_aperture_width = Fraction(clean_aperture_width_num, - clean_aperture_width_den); - m_clean_aperture_height = Fraction(clean_aperture_height_num, -@@ -2420,8 +2438,8 @@ void Box_clap::set(uint32_t clap_width, uint32_t clap_height, - assert(image_width >= clap_width); - assert(image_height >= clap_height); - -- m_clean_aperture_width = Fraction(clap_width, 1); -- m_clean_aperture_height = Fraction(clap_height, 1); -+ m_clean_aperture_width = Fraction(clap_width, 1U); -+ m_clean_aperture_height = Fraction(clap_height, 1U); - - m_horizontal_offset = Fraction(-(int32_t) (image_width - clap_width), 2); - m_vertical_offset = Fraction(-(int32_t) (image_height - clap_height), 2); diff --git a/libheif/linux/libheif/024-fix-avif-left-shift-ub.patch b/libheif/linux/libheif/024-fix-avif-left-shift-ub.patch deleted file mode 100644 index 9c69620e..00000000 --- a/libheif/linux/libheif/024-fix-avif-left-shift-ub.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 82070385eca01f64c587e02c0a75d60386d308c3 Mon Sep 17 00:00:00 2001 -From: Joachim Bauch -Date: Fri, 14 May 2021 09:11:25 +0200 -Subject: [PATCH] Fix undefined behaviour from left shift. - -Found by Coverity Scan. ---- - libheif/heif_avif.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libheif/heif_avif.cc b/libheif/heif_avif.cc -index bd233b37..47e858a9 100644 ---- a/libheif/heif_avif.cc -+++ b/libheif/heif_avif.cc -@@ -87,7 +87,7 @@ static uint64_t leb128(BitReader& reader) - { - uint64_t val = 0; - for (int i = 0; i < 8; i++) { -- int v = reader.get_bits(8); -+ int64_t v = reader.get_bits(8); - val |= (v & 0x7F) << (i * 7); - if (!(v & 0x80)) { - break; diff --git a/libheif/linux/libheif/025-fix-bitstream-potential-overflow.patch b/libheif/linux/libheif/025-fix-bitstream-potential-overflow.patch deleted file mode 100644 index 2ac953b6..00000000 --- a/libheif/linux/libheif/025-fix-bitstream-potential-overflow.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 67410c3ce2c8a210d42d02c790c3ac1f9791605a Mon Sep 17 00:00:00 2001 -From: Joachim Bauch -Date: Fri, 14 May 2021 09:14:12 +0200 -Subject: [PATCH] Calculate with 64bit to avoid potential overflow. - -Found by Coverity Scan. ---- - libheif/bitstream.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libheif/bitstream.h b/libheif/bitstream.h -index b694cf4d..48c4c5a8 100644 ---- a/libheif/bitstream.h -+++ b/libheif/bitstream.h -@@ -272,7 +272,7 @@ namespace heif { - - int64_t get_bits_remaining() const - { -- return bytes_remaining*8 + nextbits_cnt; -+ return ((int64_t) bytes_remaining) * 8 + nextbits_cnt; - } - - private: diff --git a/libheif/linux/libheif/026-fix-encoder-no-SPS-returned-1.patch b/libheif/linux/libheif/026-fix-encoder-no-SPS-returned-1.patch deleted file mode 100644 index 7701a60d..00000000 --- a/libheif/linux/libheif/026-fix-encoder-no-SPS-returned-1.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 2611d39704bdb6bb37429e39660d9dedbdfff35a Mon Sep 17 00:00:00 2001 -From: Joachim Bauch -Date: Fri, 14 May 2021 09:32:50 +0200 -Subject: [PATCH] Assume encoded image has source size if no SPS is returned - from encoder. - -Found by Coverity Scan. ---- - libheif/heif_context.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/libheif/heif_context.cc b/libheif/heif_context.cc -index d536c0f9..871d7824 100644 ---- a/libheif/heif_context.cc -+++ b/libheif/heif_context.cc -@@ -1966,7 +1966,8 @@ Error HeifContext::encode_image_as_hevc(std::shared_ptr image, - err.message); - } - -- int encoded_width, encoded_height; -+ int encoded_width = image->get_width(heif_channel_Y); -+ int encoded_height = image->get_height(heif_channel_Y); - - for (;;) { - uint8_t* data; diff --git a/libheif/linux/libheif/027-fix-check-results-of-read.patch b/libheif/linux/libheif/027-fix-check-results-of-read.patch deleted file mode 100644 index 49f93801..00000000 --- a/libheif/linux/libheif/027-fix-check-results-of-read.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 5a20339c29831cd2f72903a1ca2ff88e458dc1c2 Mon Sep 17 00:00:00 2001 -From: Joachim Bauch -Date: Fri, 14 May 2021 09:35:32 +0200 -Subject: [PATCH] Check result of "read" call (available data was already - checked above). - -Found by Coverity Scan. ---- - libheif/box.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/libheif/box.cc b/libheif/box.cc -index ce5362a5..25958385 100644 ---- a/libheif/box.cc -+++ b/libheif/box.cc -@@ -240,7 +240,9 @@ heif::Error heif::BoxHeader::parse(BitstreamRange& range) - - if (range.prepare_read(16)) { - m_uuid_type.resize(16); -- range.get_istream()->read((char*) m_uuid_type.data(), 16); -+ bool success = range.get_istream()->read((char*) m_uuid_type.data(), 16); -+ assert(success); -+ (void) success; - } - - m_header_size += 16; -@@ -2666,7 +2668,9 @@ Error Box_hvcC::parse(BitstreamRange& range) - - if (range.prepare_read(size)) { - nal_unit.resize(size); -- range.get_istream()->read((char*) nal_unit.data(), size); -+ bool success = range.get_istream()->read((char*) nal_unit.data(), size); -+ assert(success); -+ (void) success; - } - - array.m_nal_units.push_back(std::move(nal_unit)); diff --git a/libheif/linux/libheif/028-fix-encoder-no-SPS-returned-2.patch b/libheif/linux/libheif/028-fix-encoder-no-SPS-returned-2.patch deleted file mode 100644 index 26c1bcc3..00000000 --- a/libheif/linux/libheif/028-fix-encoder-no-SPS-returned-2.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 98b867ea575ecce7039458b71f2c320742489e30 Mon Sep 17 00:00:00 2001 -From: Joachim Bauch -Date: Tue, 14 Dec 2021 12:18:00 +0100 -Subject: [PATCH] Return error if no SPS / no encoded width or height. - ---- - libheif/heif_context.cc | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/libheif/heif_context.cc b/libheif/heif_context.cc -index 871d7824..3eac29fc 100644 ---- a/libheif/heif_context.cc -+++ b/libheif/heif_context.cc -@@ -1966,8 +1966,8 @@ Error HeifContext::encode_image_as_hevc(std::shared_ptr image, - err.message); - } - -- int encoded_width = image->get_width(heif_channel_Y); -- int encoded_height = image->get_height(heif_channel_Y); -+ int encoded_width = 0; -+ int encoded_height = 0; - - for (;;) { - uint8_t* data; -@@ -2002,6 +2002,10 @@ Error HeifContext::encode_image_as_hevc(std::shared_ptr image, - } - } - -+ if (!encoded_width || !encoded_height) { -+ return Error(heif_error_Encoder_plugin_error, -+ heif_suberror_Invalid_image_size); -+ } - - // if image size was rounded up to even size, add a 'clap' box to crop the - // padding border away diff --git a/libheif/linux/libheif/029-fix-nclx-avoid-division-by-zero.patch b/libheif/linux/libheif/029-fix-nclx-avoid-division-by-zero.patch deleted file mode 100644 index 1c968513..00000000 --- a/libheif/linux/libheif/029-fix-nclx-avoid-division-by-zero.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 9497e10168660138fd10a738179039c0e7d7ba6c Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 21 Feb 2022 20:38:13 +0100 -Subject: [PATCH] avoid division by zero (should never happen) - ---- - libheif/nclx.cc | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/libheif/nclx.cc b/libheif/nclx.cc -index 0c35b6cd..b81b7d7c 100644 ---- a/libheif/nclx.cc -+++ b/libheif/nclx.cc -@@ -82,6 +82,10 @@ heif::Kr_Kb heif::get_Kr_Kb(uint16_t matrix_coefficients_idx, uint16_t primaries - float denom = p.whiteY * (p.redX * (p.greenY * zb - p.blueY * zg) + p.greenX * (p.blueY * zr - p.redY * zb) + - p.blueX * (p.redY * zg - p.greenY * zr)); - -+ if (denom == 0.0f) { -+ return result; -+ } -+ - result.Kr = (p.redY * (p.whiteX * (p.greenY * zb - p.blueY * zg) + p.whiteY * (p.blueX * zg - p.greenX * zb) + - zw * (p.greenX * p.blueY - p.blueX * p.greenY))) / denom; - result.Kb = (p.blueY * (p.whiteX * (p.redY * zg - p.greenY * zr) + p.whiteY * (p.greenX * zr - p.redX * zg) + diff --git a/libheif/linux/libheif/030-fix-wrong-copy-size.patch b/libheif/linux/libheif/030-fix-wrong-copy-size.patch deleted file mode 100644 index 34739410..00000000 --- a/libheif/linux/libheif/030-fix-wrong-copy-size.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 11ffeffadd980f9f96019fe180fc1e81827e3790 Mon Sep 17 00:00:00 2001 -From: Dirk Farin -Date: Mon, 4 Apr 2022 20:43:45 +0200 -Subject: [PATCH] fix wrong memcpy size - ---- - libheif/heif_colorconversion.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/libheif/heif_colorconversion.cc b/libheif/heif_colorconversion.cc -index 2b050684..5a07ebb7 100644 ---- a/libheif/heif_colorconversion.cc -+++ b/libheif/heif_colorconversion.cc -@@ -526,7 +526,8 @@ Op_YCbCr_to_RGB::convert_colorspace(const std::shared_ptr bool: @@ -74,29 +74,7 @@ def build_lib_linux(url: str, name: str, musl: bool = False): run(f"patch -p 1 -i {patch_path}".split(), check=True) elif name == "libheif": chdir(_lib_path) - for patch in ( - "libheif/010-fix-loading-alpha-image.patch", - "libheif/011-fix-loading-alpha-image.patch", - "libheif/012-fix-do-not-pad-16x16-AOM.patch", - "libheif/013-fix-enable-lossless-AOM.patch", - "libheif/014-fix-RGB-to-YCbCr-chroma.patch", - "libheif/015-fix-RRGGBB-to-YCbCr-chroma.patch", - "libheif/016-fix-RGB-to-YCbCr-chroma-2.patch", - "libheif/017-fix-aom-signal-chroma-position.patch", - "libheif/018-expose-aom-decoder-errors.patch", - "libheif/019-aom-all-intra.patch", - "libheif/020-fix-scaling-of-images.patch", - "libheif/021-fix-clap-box-dimensions-1.diff", - "libheif/022-fix-clap-box-dimensions-2.patch", - "libheif/023-fix-clap-box-dimensions-3.patch", - "libheif/024-fix-avif-left-shift-ub.patch", - "libheif/025-fix-bitstream-potential-overflow.patch", - "libheif/026-fix-encoder-no-SPS-returned-1.patch", - "libheif/027-fix-check-results-of-read.patch", - "libheif/028-fix-encoder-no-SPS-returned-2.patch", - "libheif/029-fix-nclx-avoid-division-by-zero.patch", - "libheif/030-fix-wrong-copy-size.patch", - ): + for patch in ("libheif/001-aom-remove-extend_padding_to_size.patch",): patch_path = path.join(_linux_dir, patch) run(f"patch -p 1 -i {patch_path}".split(), check=True) chdir(_build_path) @@ -177,7 +155,7 @@ def build_libs() -> str: return INSTALL_DIR_LIBS _original_dir = getcwd() try: - linux_build_tools.build_tools(_is_musllinux) + linux_build_tools.build_tools(_is_musllinux, machine().find("armv7") != -1) if not is_library_installed("x265"): if not PH_LIGHT_VERSION: build_lib_linux( @@ -209,13 +187,13 @@ def build_libs() -> str: print("libde265 already installed.") if machine().find("armv7") == -1: build_lib_linux( - "https://github.com/strukturag/libheif/releases/download/v1.12.0/libheif-1.12.0.tar.gz", + "https://github.com/strukturag/libheif/releases/download/v1.13.0/libheif-1.13.0.tar.gz", "libheif", _is_musllinux, ) else: build_lib_linux_armv7( - "https://github.com/strukturag/libheif/releases/download/v1.12.0/libheif-1.12.0.tar.gz", + "https://github.com/strukturag/libheif/releases/download/v1.13.0/libheif-1.13.0.tar.gz", "libheif", _is_musllinux, ) diff --git a/libheif/linux_build_tools.py b/libheif/linux_build_tools.py index 074d99fe..9864262b 100644 --- a/libheif/linux_build_tools.py +++ b/libheif/linux_build_tools.py @@ -1,5 +1,4 @@ from os import chdir, environ, makedirs, path, remove -from platform import machine from re import IGNORECASE, MULTILINE, search from subprocess import DEVNULL, PIPE, CalledProcessError, TimeoutExpired, run @@ -95,8 +94,8 @@ def tool_check_version(name: str, min_version: str) -> bool: return False -def build_tools(musl: bool = False): - if machine().find("armv7") != -1: +def build_tools(musl: bool, armv7: bool): + if armv7: build_tool( "https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz", "pkg-config", diff --git a/libheif/macos/libheif.rb b/libheif/macos/libheif.rb index 93f17c8b..37fba98e 100644 --- a/libheif/macos/libheif.rb +++ b/libheif/macos/libheif.rb @@ -3,11 +3,11 @@ class Libheif < Formula desc "ISO/IEC 23008-12:2017 HEIF file format decoder and encoder" homepage "https://www.libde265.org/" - url "https://github.com/strukturag/libheif/releases/download/v1.12.0/libheif-1.12.0.tar.gz" - sha256 "e1ac2abb354fdc8ccdca71363ebad7503ad731c84022cf460837f0839e171718" + url "https://github.com/strukturag/libheif/releases/download/v1.13.0/libheif-1.13.0.tar.gz" + sha256 "c20ae01bace39e89298f6352f1ff4a54b415b33b9743902da798e8a1e51d7ca1" license "LGPL-3.0-only" # Set current revision from what it was taken plus 10 - revision 12 + revision 10 depends_on "pkg-config" => :build depends_on "aom" @@ -17,136 +17,9 @@ class Libheif < Formula depends_on "shared-mime-info" depends_on "x265" - # Fix -flat_namespace being used on Big Sur and later. patch do - url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-big_sur.diff" - sha256 "35acd6aebc19843f1a2b3a63e880baceb0f5278ab1ace661e57a502d9d78c93c" - end - - # (010) Fix loading alpha image - patch do - url "https://github.com/strukturag/libheif/commit/4795ba10abd233024d0536096182133fa06d9c3b.patch" - sha256 "74b6ab5c85307944a292c8044bd8dee4645d413775f8c669b44b63a0cfe81436" - end - - # (011) - patch do - url "https://github.com/strukturag/libheif/commit/c32f15512323960097b99c204535ec53d11fb355.patch" - sha256 "75ac6e6ca7cecf9bedeb23d21bc60cbc17bf5dcae1c82d39bf388f8d30c6f916" - end - - # (012) AOM: Fix do not pad minimum to 16x16 pixels - patch do - url "https://github.com/strukturag/libheif/commit/ec1dc464dc08517ecef7b675043886ec727eadb2.patch" - sha256 "0d2a3727e494cb328f5b786d4bb116d167026a86a709219768ab47ed4d2c73c8" - end - - # (013) AOM: enable lossless - patch do - url "https://github.com/strukturag/libheif/commit/b2612dd9c63f8835cf2047960b8cacd464a325a4.patch" - sha256 "d9747b6191ea142df649166de7cfa4ddb4012530802906c5e0626aed20705325" - end - - # (014) Fix RGB(A) to YCbCr chroma position - patch do - url "https://github.com/strukturag/libheif/commit/2c8d963dfc0b967e6c78259ba0a99185b27206d8.patch" - sha256 "5c235e94a6e0ed644942ec9824110800566e750ba9a9a90e92a8d03dd520ae08" - end - - # (015) Fix RRGGBB to YCbCr chroma position - patch do - url "https://github.com/strukturag/libheif/commit/ab0af732fd3c2ebf0211a0a072c76789c8d38d39.patch" - sha256 "3ba2ae48158b1362edcdd46b8ee56c88f93e540152da7408a429917ccf2bd5bd" - end - - # (016) Fix RGB to YCbCr chroma sampling position at center(2) - patch do - url "https://github.com/strukturag/libheif/commit/2dfc9b2c04ce77c0d85af37a4f66c0ee2dbe058d.patch" - sha256 "ab9b658197542bcc0d6ed28ebef1879da2b75bcb7ce8d267be90ee998649a523" - end - - # (017) AVIF: signal chroma sample position when encoding - patch do - url "https://github.com/strukturag/libheif/commit/487c3d821df79178edd18a62285449d8d1f70160.patch" - sha256 "8eda9cf854cd4084a97b8a0c770bf183cc4f567e6a9e1f66288fa27957e26df3" - end - - # (018) AOM: expose aom decoder errors - patch do - url "https://github.com/strukturag/libheif/commit/13c3d59be814a34ceb2ae12da1b6eab3cd85cf72.patch" - sha256 "9dd1c14838b71b9e593649d36f979c0fea6a85692f591021e06285ec9c392d50" - end - - # (019) AOM: enable all intra mode by default - patch do - url "https://github.com/strukturag/libheif/commit/4ec2ac35e2cd79e8594092f6e36b5eace19cefdf.patch" - sha256 "98b1074874c5697254f74444a64dd00cfb15ecf5544d873c5c1f2c5cb11b602b" - end - - # (020) Fix scaling of images - patch do - url "https://github.com/strukturag/libheif/commit/0cd461e18b99d018f9adef731eec928781078afb.patch" - sha256 "81f2c5de8cbd80297208cfd54e95e6f7765c896365ef531ff8f38aaa4f4f6679" - end - - # (021) Fix overflow of clap box dimensions(1) - patch do - url "https://github.com/strukturag/libheif/commit/4193d80e87133b308205d30d234436592fc70c49.diff" - sha256 "dcb87aa66ea09848e007ce8fed65848b9028b1c7456634d62da690f9c5867195" - end - - # (022) Fix clap box in supported range(2) - patch do - url "https://github.com/strukturag/libheif/commit/ca2473d9eca36697aa531f42209567cc663ceaee.patch" - sha256 "e6f107c77c8b8ffc00e12d37a11a29642b5db2aadd552fa7d7033c4368c689f2" - end - - # (023) Clap box sizes to unsigned(3) - patch do - url "https://github.com/strukturag/libheif/commit/2c4cb5712724b5617019dc749b91b0acd0f9ad7c.patch" - sha256 "a6fde7081abe1fd5d3b9bc4e850cdbb16790d2105971111c86657696bad39438" - end - - # (024) Fix AVIF left shift undefined behaviour - patch do - url "https://github.com/strukturag/libheif/commit/82070385eca01f64c587e02c0a75d60386d308c3.patch" - sha256 "64d51a24cb26af69fbca98c8394cd1682b0d16eb9a50412635a20ee153e3372b" - end - - # (025) Fix bitstream potential overflow - patch do - url "https://github.com/strukturag/libheif/commit/67410c3ce2c8a210d42d02c790c3ac1f9791605a.patch" - sha256 "368a8965118647a8e7ca6e9b454cac94b72f3b26711bfd3d371e274b59b94007" - end - - # (026) Fix encoder when no SPS returned(1) - patch do - url "https://github.com/strukturag/libheif/commit/2611d39704bdb6bb37429e39660d9dedbdfff35a.patch" - sha256 "7cbca7d0f8f6743d0997a3b5102a1397eb967261e96c8946ad70e195d93cc24f" - end - - # (027) Fix checking result of `read` - patch do - url "https://github.com/strukturag/libheif/commit/5a20339c29831cd2f72903a1ca2ff88e458dc1c2.patch" - sha256 "a07fc8974cf1f0634c158c72ac6c3263457c6d91a0e66143607c9ee2fcb72feb" - end - - # (028) Fix encoder when no SPS returned(2) - patch do - url "https://github.com/strukturag/libheif/commit/98b867ea575ecce7039458b71f2c320742489e30.patch" - sha256 "1e063aef2a871526e99247615d439bc7055034e443d5537d6702db09a470a9f9" - end - - # (029) NCLX: avoid division by zero - patch do - url "https://github.com/strukturag/libheif/commit/9497e10168660138fd10a738179039c0e7d7ba6c.patch" - sha256 "97fc5e57727d9ea47aa7dbdf2635afd40122ca1a0f9d44be228d3d14efd7c610" - end - - # (030) Fix wrong copy size - patch do - url "https://github.com/strukturag/libheif/commit/11ffeffadd980f9f96019fe180fc1e81827e3790.patch" - sha256 "1a5ea2b0afe73b233daa7a693a9891c0096565f6d72a65a135b05c88e839395a" + url "https://github.com/strukturag/libheif/commit/a01baccaf40bafcabddba47846f5e914ca0724f6.patch" + sha256 "0f910768a2e031b2171c477bcfb9e82d03d970abcd1bbd6dc0ec3ce06fa2ec2c" end def install @@ -169,7 +42,7 @@ def post_install assert_predicate testpath/"exampleheic-1.jpg", :exist? assert_predicate testpath/"exampleheic-2.jpg", :exist? - output = "File contains 1 images" + output = "File contains 1 image" example = pkgshare/"example.avif" exout = testpath/"exampleavif.jpg" diff --git a/libheif/windows/mingw-w64-libheif/001-fix-pkgconfig-provide-includedir.patch b/libheif/windows/mingw-w64-libheif/001-fix-pkgconfig-provide-includedir.patch deleted file mode 100644 index d20693fb..00000000 --- a/libheif/windows/mingw-w64-libheif/001-fix-pkgconfig-provide-includedir.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- libheif-1.4.0/libheif.pc.in.orig 2019-06-11 09:44:59.145657700 +0300 -+++ libheif-1.4.0/libheif.pc.in 2019-06-11 09:45:12.764481600 +0300 -@@ -1,7 +1,7 @@ - prefix=@prefix@ - exec_prefix=@exec_prefix@ - libdir=@libdir@ --includedir=@includedir@ -+includedir=@includedir@/@PACKAGE@ - builtin_h265_decoder=@have_libde265@ - builtin_h265_encoder=@have_x265@ - -@@ -12,4 +12,4 @@ - Requires: - Libs: -L@libdir@ -lheif - Libs.private: @LIBS@ -lstdc++ --Cflags: -I@includedir@ -+Cflags: -I@includedir@/@PACKAGE@ ---- libheif-1.11.0/CMakeLists.txt.orig 2021-02-01 15:14:13.000000000 +0100 -+++ libheif-1.11.0/CMakeLists.txt 2021-04-29 11:05:30.779610800 +0200 -@@ -152,7 +152,8 @@ - set(have_avif_encoder no) - endif() - list(JOIN REQUIRES_PRIVATE " " REQUIRES_PRIVATE) --set(VERSION ${PROJECT_VERSION}) -+set(VERSION ${PACKAGE_VERSION}) -+set(PACKAGE ${PROJECT_NAME}) - - configure_file(libheif.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libheif.pc @ONLY) - diff --git a/libheif/windows/mingw-w64-libheif/002-cmake-enable-gdk-pixbuf.patch b/libheif/windows/mingw-w64-libheif/002-cmake-enable-gdk-pixbuf.patch deleted file mode 100644 index 1994aa0f..00000000 --- a/libheif/windows/mingw-w64-libheif/002-cmake-enable-gdk-pixbuf.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- libheif-1.11.0/gdk-pixbuf/CMakeLists.txt.orig 2021-01-24 20:56:53.000000000 +0100 -+++ libheif-1.11.0/gdk-pixbuf/CMakeLists.txt 2021-04-29 10:25:26.355235000 +0200 -@@ -1,4 +1,4 @@ --if(UNIX) -+if(UNIX OR MINGW) - find_package(PkgConfig) - find_package(Threads) - pkg_check_modules(GDKPIXBUF2 gdk-pixbuf-2.0) -@@ -6,7 +6,7 @@ - if(GDKPIXBUF2_FOUND) - execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} gdk-pixbuf-2.0 --variable gdk_pixbuf_moduledir --define-variable=prefix=${CMAKE_INSTALL_PREFIX} OUTPUT_VARIABLE GDKPIXBUF2_MODULE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) - -- add_library(pixbufloader-heif MODULE pixbufloader-heif.c) -+ add_library(pixbufloader-heif pixbufloader-heif.c) - - target_include_directories(pixbufloader-heif - PRIVATE -@@ -15,6 +15,6 @@ - ${libheif_SOURCE_DIR}) - target_link_libraries(pixbufloader-heif PUBLIC ${GDKPIXBUF2_LIBRARIES} heif) - -- install(TARGETS pixbufloader-heif LIBRARY DESTINATION ${GDKPIXBUF2_MODULE_DIR}) -+ install(TARGETS pixbufloader-heif DESTINATION ${GDKPIXBUF2_MODULE_DIR}) - endif() - endif() diff --git a/libheif/windows/mingw-w64-libheif/PKGBUILD b/libheif/windows/mingw-w64-libheif/PKGBUILD index 8412a9d3..cddc61cf 100644 --- a/libheif/windows/mingw-w64-libheif/PKGBUILD +++ b/libheif/windows/mingw-w64-libheif/PKGBUILD @@ -1,11 +1,11 @@ # Contributor: Edward E. -# source: https://github.com/msys2/MINGW-packages/blob/a68642280eceb8fbc498d3e715063ce8f325b2f0/mingw-w64-libheif/PKGBUILD +# source: https://github.com/msys2/MINGW-packages/blob/96d4043cfa8d82645da2ff44446ceb58873df242/mingw-w64-libheif/PKGBUILD _realname=libheif pkgbase=mingw-w64-${_realname} pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") -pkgver=1.12.0 -pkgrel=9 +pkgver=1.13.0 +pkgrel=2 pkgdesc="HEIF image decoder/encoder library and tools (mingw-w64)" arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') @@ -24,91 +24,19 @@ depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-libwinpthread-git" "${MINGW_PACKAGE_PREFIX}-x265") source=("https://github.com/strukturag/libheif/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz" - "001-fix-pkgconfig-provide-includedir.patch" - "002-cmake-enable-gdk-pixbuf.patch" - "003-cmake-install-headers.patch"::"https://patch-diff.githubusercontent.com/raw/strukturag/libheif/pull/499.diff" - "004-cmake-install-manpages.patch"::"https://patch-diff.githubusercontent.com/raw/strukturag/libheif/pull/500.diff" - "005-cmake-install-gnome-thumb.patch"::"https://patch-diff.githubusercontent.com/raw/strukturag/libheif/pull/501.diff" - "006-mingw-enable-wchar.patch"::"https://github.com/strukturag/libheif/commit/c4acdc562f89a5fae69f9a961421ca1ac2a7429d.diff" - "010-fix-loading-alpha-image.patch"::"https://github.com/strukturag/libheif/commit/4795ba10abd233024d0536096182133fa06d9c3b.patch" - "011-fix-loading-alpha-image.patch"::"https://github.com/strukturag/libheif/commit/c32f15512323960097b99c204535ec53d11fb355.patch" - "012-fix-do-not-pad-16x16-AOM.patch"::"https://github.com/strukturag/libheif/commit/ec1dc464dc08517ecef7b675043886ec727eadb2.patch" - "013-fix-enable-lossless-AOM.patch"::"https://github.com/strukturag/libheif/commit/b2612dd9c63f8835cf2047960b8cacd464a325a4.patch" - "014-fix-RGB-to-YCbCr-chroma.patch"::"https://github.com/strukturag/libheif/commit/2c8d963dfc0b967e6c78259ba0a99185b27206d8.patch" - "015-fix-RRGGBB-to-YCbCr-chroma.patch"::"https://github.com/strukturag/libheif/commit/ab0af732fd3c2ebf0211a0a072c76789c8d38d39.patch" - "016-fix-RGB-to-YCbCr-chroma-2.patch"::"https://github.com/strukturag/libheif/commit/2dfc9b2c04ce77c0d85af37a4f66c0ee2dbe058d.patch" - "017-fix-aom-signal-chroma-position.patch"::"https://github.com/strukturag/libheif/commit/487c3d821df79178edd18a62285449d8d1f70160.patch" - "018-expose-aom-decoder-errors.patch"::"https://github.com/strukturag/libheif/commit/13c3d59be814a34ceb2ae12da1b6eab3cd85cf72.patch" - "019-aom-all-intra.patch"::"https://github.com/strukturag/libheif/commit/4ec2ac35e2cd79e8594092f6e36b5eace19cefdf.patch" - "020-fix-scaling-of-images.patch"::"https://github.com/strukturag/libheif/commit/0cd461e18b99d018f9adef731eec928781078afb.patch" - "021-fix-clap-box-dimensions-1.diff"::"https://github.com/strukturag/libheif/commit/4193d80e87133b308205d30d234436592fc70c49.diff" - "022-fix-clap-box-dimensions-2.patch"::"https://github.com/strukturag/libheif/commit/ca2473d9eca36697aa531f42209567cc663ceaee.patch" - "023-fix-clap-box-dimensions-3.patch"::"https://github.com/strukturag/libheif/commit/2c4cb5712724b5617019dc749b91b0acd0f9ad7c.patch" - "024-fix-avif-left-shift-ub.patch"::"https://github.com/strukturag/libheif/commit/82070385eca01f64c587e02c0a75d60386d308c3.patch" - "025-fix-bitstream-potential-overflow.patch"::"https://github.com/strukturag/libheif/commit/67410c3ce2c8a210d42d02c790c3ac1f9791605a.patch" - "026-fix-encoder-no-SPS-returned-1.patch"::"https://github.com/strukturag/libheif/commit/2611d39704bdb6bb37429e39660d9dedbdfff35a.patch" - "027-fix-check-results-of-read.patch"::"https://github.com/strukturag/libheif/commit/5a20339c29831cd2f72903a1ca2ff88e458dc1c2.patch" - "028-fix-encoder-no-SPS-returned-2.patch"::"https://github.com/strukturag/libheif/commit/98b867ea575ecce7039458b71f2c320742489e30.patch" - "029-fix-nclx-avoid-division-by-zero.patch"::"https://github.com/strukturag/libheif/commit/9497e10168660138fd10a738179039c0e7d7ba6c.patch" - "030-fix-wrong-copy-size.patch"::"https://github.com/strukturag/libheif/commit/11ffeffadd980f9f96019fe180fc1e81827e3790.patch") -sha256sums=('e1ac2abb354fdc8ccdca71363ebad7503ad731c84022cf460837f0839e171718' - 'd6bb42bdd884592d1edd3eb69ebc927de4fc329fbc05fab921b0aee23b68b124' - '51012f7d84bd3d177839d99aaae2df388e42bd51a95bceac4329be81358895e2' - '8944e9953b2924b581cf688a3dc7483cbd0f208a24dda81963e70a45db16fd48' - '02e026708b01f2a86c6ddb9346fb7bd4cd9e43b5c0a598116255f2bdb1e5cc74' - '38ae18671817313c58f7c33e337c1f82aaf483c07e9fda541750965d99ee6f07' - '43702c66c3e9e530199c6f1d6809ff371e9a4ccb2a253df79eec687dad3de43f' - '74b6ab5c85307944a292c8044bd8dee4645d413775f8c669b44b63a0cfe81436' - '75ac6e6ca7cecf9bedeb23d21bc60cbc17bf5dcae1c82d39bf388f8d30c6f916' - '0d2a3727e494cb328f5b786d4bb116d167026a86a709219768ab47ed4d2c73c8' - 'd9747b6191ea142df649166de7cfa4ddb4012530802906c5e0626aed20705325' - '5c235e94a6e0ed644942ec9824110800566e750ba9a9a90e92a8d03dd520ae08' - '3ba2ae48158b1362edcdd46b8ee56c88f93e540152da7408a429917ccf2bd5bd' - 'ab9b658197542bcc0d6ed28ebef1879da2b75bcb7ce8d267be90ee998649a523' - '8eda9cf854cd4084a97b8a0c770bf183cc4f567e6a9e1f66288fa27957e26df3' - '9dd1c14838b71b9e593649d36f979c0fea6a85692f591021e06285ec9c392d50' - '98b1074874c5697254f74444a64dd00cfb15ecf5544d873c5c1f2c5cb11b602b' - '81f2c5de8cbd80297208cfd54e95e6f7765c896365ef531ff8f38aaa4f4f6679' - 'dcb87aa66ea09848e007ce8fed65848b9028b1c7456634d62da690f9c5867195' - 'e6f107c77c8b8ffc00e12d37a11a29642b5db2aadd552fa7d7033c4368c689f2' - 'a6fde7081abe1fd5d3b9bc4e850cdbb16790d2105971111c86657696bad39438' - '64d51a24cb26af69fbca98c8394cd1682b0d16eb9a50412635a20ee153e3372b' - '368a8965118647a8e7ca6e9b454cac94b72f3b26711bfd3d371e274b59b94007' - '7cbca7d0f8f6743d0997a3b5102a1397eb967261e96c8946ad70e195d93cc24f' - 'a07fc8974cf1f0634c158c72ac6c3263457c6d91a0e66143607c9ee2fcb72feb' - '1e063aef2a871526e99247615d439bc7055034e443d5537d6702db09a470a9f9' - '97fc5e57727d9ea47aa7dbdf2635afd40122ca1a0f9d44be228d3d14efd7c610' - '1a5ea2b0afe73b233daa7a693a9891c0096565f6d72a65a135b05c88e839395a') + "001-pkgconfig-match-autotools.patch"::"https://patch-diff.githubusercontent.com/raw/strukturag/libheif/pull/529.diff" + "002-cmake-enable-gdk-pixbuf.patch"::"https://patch-diff.githubusercontent.com/raw/strukturag/libheif/pull/647.diff" + "003-aom-remove-extend_padding_to_size.patch"::"https://github.com/strukturag/libheif/commit/a01baccaf40bafcabddba47846f5e914ca0724f6.patch") +sha256sums=('c20ae01bace39e89298f6352f1ff4a54b415b33b9743902da798e8a1e51d7ca1' + '9f9a1ee8161643c44cc7813cdd4d8721ab3e67b5262cf4a29988307fd667f4ae' + '9aea63f92de2d71a0d021baf2d31df39f9633b16d715c11572cf54e64bb4a52d' + '0f910768a2e031b2171c477bcfb9e82d03d970abcd1bbd6dc0ec3ce06fa2ec2c') prepare() { cd "${srcdir}/${_realname}-${pkgver}" - patch -Np1 -i "${srcdir}/001-fix-pkgconfig-provide-includedir.patch" + patch -Np1 -i "${srcdir}/001-pkgconfig-match-autotools.patch" patch -Np1 -i "${srcdir}/002-cmake-enable-gdk-pixbuf.patch" - patch -Np1 -i "${srcdir}/003-cmake-install-headers.patch" - patch -Np1 -i "${srcdir}/004-cmake-install-manpages.patch" - patch -Np1 -i "${srcdir}/005-cmake-install-gnome-thumb.patch" - patch -Np1 -i "${srcdir}/006-mingw-enable-wchar.patch" - patch -Np1 -i "${srcdir}/010-fix-loading-alpha-image.patch" - patch -Np1 -i "${srcdir}/011-fix-loading-alpha-image.patch" - patch -Np1 -i "${srcdir}/012-fix-do-not-pad-16x16-AOM.patch" - patch -Np1 -i "${srcdir}/013-fix-enable-lossless-AOM.patch" - patch -Np1 -i "${srcdir}/014-fix-RGB-to-YCbCr-chroma.patch" - patch -Np1 -i "${srcdir}/015-fix-RRGGBB-to-YCbCr-chroma.patch" - patch -Np1 -i "${srcdir}/016-fix-RGB-to-YCbCr-chroma-2.patch" - patch -Np1 -i "${srcdir}/017-fix-aom-signal-chroma-position.patch" - patch -Np1 -i "${srcdir}/018-expose-aom-decoder-errors.patch" - patch -Np1 -i "${srcdir}/019-aom-all-intra.patch" - patch -Np1 -i "${srcdir}/020-fix-scaling-of-images.patch" - patch -Np1 -i "${srcdir}/021-fix-clap-box-dimensions-1.diff" - patch -Np1 -i "${srcdir}/022-fix-clap-box-dimensions-2.patch" - patch -Np1 -i "${srcdir}/023-fix-clap-box-dimensions-3.patch" - patch -Np1 -i "${srcdir}/024-fix-avif-left-shift-ub.patch" - patch -Np1 -i "${srcdir}/025-fix-bitstream-potential-overflow.patch" - patch -Np1 -i "${srcdir}/026-fix-encoder-no-SPS-returned-1.patch" - patch -Np1 -i "${srcdir}/027-fix-check-results-of-read.patch" - patch -Np1 -i "${srcdir}/028-fix-encoder-no-SPS-returned-2.patch" - patch -Np1 -i "${srcdir}/029-fix-nclx-avoid-division-by-zero.patch" - patch -Np1 -i "${srcdir}/030-fix-wrong-copy-size.patch" + patch -Np1 -i "${srcdir}/003-aom-remove-extend_padding_to_size.patch" } build() { diff --git a/pi-heif/README.md b/pi-heif/README.md index 102aac84..61329bfa 100644 --- a/pi-heif/README.md +++ b/pi-heif/README.md @@ -5,6 +5,10 @@ ![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black) ![Alpine Linux](https://img.shields.io/badge/Alpine_Linux-0078D6.svg?style=for-the-badge&logo=alpine-linux&logoColor=white) + +# UNDER DEVELOPMENT + + This is a light version of [Pillow-Heif](https://github.com/bigcat88/pillow_heif) with more permissive license for binary wheels. This version includes only `HEIF` decoder and does not support `save` operations.