Skip to content

Support HEIC image encoding with libkvazaar#906

Draft
cmb69 wants to merge 1 commit into
libgd:masterfrom
cmb69:cmb/kvazaar-encode
Draft

Support HEIC image encoding with libkvazaar#906
cmb69 wants to merge 1 commit into
libgd:masterfrom
cmb69:cmb/kvazaar-encode

Conversation

@cmb69

@cmb69 cmb69 commented Dec 22, 2024

Copy link
Copy Markdown
Member

libheif currently supports x265 and kvazaar for encoding HEIC images; while the former is recommended, the latter has a more liberal license, and as such is an interesting alternative. However, kvazaar apparently does not yet support changing the chroma subsampling, and as such, writing HEIC images fails. We apply basically the same fix as for libheif < 1.9.0, where we just ignore the given chroma subsampling, and use whatever the encoder deems suitable (likely 420).

[1] https://github.com/strukturag/libheif?tab=readme-ov-file#compiling


Note that this fixes tests/heif/bug788 for me, and let's tests/heif/heif_im2im proceed (it now only fails due to pixel differences; likely that would happen with older libheif, too).

Also note that comparing the plugin name might be a bit brittle, but comparing the plugin ID might be too, and seems to require more ado, so maybe we're good comparing the name.

Since we support HEIF encoding not only with HEVC, but also with AV1, it seems to prudent to check whether the AV1 encoders supported by libheif (currently AOM, rav1e, and svt-av1), work as expected, or show similar limitations as kvazaar (chroma subsampling is supported by all three, but there may be other limitations).

cc @YakoYakoYokuYoku

libheif currently supports x265 and kvazaar for encoding HEIC images;
while the former is recommended, the latter has a more liberal license,
and as such is an interesting alternative.  However, kvazaar apparently
does not yet support changing the chroma subsampling, and as such,
writing HEIC images fails.  We apply basically the same fix as for
libheif < 1.9.0, where we just ignore the given chroma subsampling, and
use whatever the encoder deems suitable (likely 420).

[1] <https://github.com/strukturag/libheif?tab=readme-ov-file#compiling>
@cmb69

cmb69 commented Dec 22, 2024

Copy link
Copy Markdown
Member Author

The Ubuntu and macOS CI failures are unrelated; the Windows CI failure might be related, though. Need to check.

@cmb69 cmb69 marked this pull request as draft December 22, 2024 12:39
@cmb69

cmb69 commented Dec 22, 2024

Copy link
Copy Markdown
Member Author

I can reproduce locally with https://github.com/libgd/libgd-windows-vcpkg-prebuild; looks like a bad build (see strukturag/libheif#357 (comment)). No way to work around this. I think we need to update the dependencies for Windows anyway.

@pierrejoye

Copy link
Copy Markdown
Contributor

not sure static check/compile time is still the way. Also plugins are loaded during heiv init now if I am not mistaken. I need to read their APIs again and see if we need to call the init too from GD, introducing a gdInit() per process or thread depending on the needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants