From f2aa2836ed910ca3510585a47a8a064b5140e148 Mon Sep 17 00:00:00 2001 From: Ben Morss Date: Wed, 3 Mar 2021 21:35:56 -0500 Subject: AVIF support (#671) Demand for AVIF support on the web is growing, as the word gets out about this new file format which allows higher-quality encoding at smaller sizes. Core contributors to major open-source CMSs are interested in auto-generating AVIF images! They've been simply waiting for support to appear in libgd. This PR aims to meet the growing demand, and to help bring smaller, more beautiful images to more of the web - to sites created by experienced developers and CMS users alike. This PR adds support by incorporating libavif in addition to the existing libheif support. It's generally felt that libavif has more complete support for the AVIF format. libavif is also used by the Chromium project and squoosh.app. In this PR, I've endeavored to incorporate the latest research into best practices for AVIF encoding - not just for default quantizer values, but also an algorithm for determining the number of horizontal tiles, vertical tiles, and threads. Fixes #557. --- windows/Makefile.vc | 11 ++++++++++- windows/Makefiletest.vc | 5 +++++ windows/msys/Makefile | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'windows') diff --git a/windows/Makefile.vc b/windows/Makefile.vc index d97b22f..3fefe80 100644 --- a/windows/Makefile.vc +++ b/windows/Makefile.vc @@ -95,10 +95,11 @@ LIB_OBJS= \ $(LIBGD_OBJ_DIR)\gd_crop.obj \ $(LIBGD_OBJ_DIR)\gd_color_map.obj \ $(LIBGD_OBJ_DIR)\gd_heif.obj \ + $(LIBGD_OBJ_DIR)\gd_avif.obj \ $(LIBGD_OBJ_DIR)\gd_webp.obj LIBS=kernel32.lib ole32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib Dnsapi.lib Gdi32.Lib -LIBS_GD=libjpeg_a.lib freetype_a.lib libpng_a.lib libiconv_a.lib zlib_a.lib libheif_a.lib libwebp_a.lib libxpm_a.lib libtiff.lib +LIBS_GD=libjpeg_a.lib freetype_a.lib libpng_a.lib libiconv_a.lib zlib_a.lib libheif_a.lib libwebp_a.lib libxpm_a.lib libavif_a.lib libtiff.lib PROG_EXES= \ $(LIBGD_OBJ_DIR)\gdcmpgif.exe \ @@ -135,11 +136,13 @@ CFLAGS= $(CFLAGS) \ /DHAVE_FT2BUILD_H=1\ /DHAVE_GD_H=1\ /DHAVE_ICONV_H=1\ + /DHAVE_LIBAVIF=1\ /DHAVE_LIBFREETYPE=1\ /DHAVE_LIBJPEG=1\ /DHAVE_LIBPNG=1\ /DHAVE_LIBWEBP=1\ /DHAVE_LIBHEIF=1\ + /DHAVE_LIBAVIF=1\ /DHAVE_LIBZ=1\ /DHAVE_LIBXPM=1\ /DHAVE_LIBTIFF=1\ @@ -186,6 +189,9 @@ make_dirs: @echo #ifndef HAVE_ICONV_H>> $(GD_CONFIG_H) @echo #define HAVE_ICONV_H>> $(GD_CONFIG_H) @echo #endif>> $(GD_CONFIG_H) + @echo #ifndef HAVE_LIBAVIF>> $(GD_CONFIG_H) + @echo #define HAVE_LIBAVIF>> $(GD_CONFIG_H) + @echo #endif>> $(GD_CONFIG_H) @echo #ifndef HAVE_LIBFREETYPE>> $(GD_CONFIG_H) @echo #define HAVE_LIBFREETYPE>> $(GD_CONFIG_H) @echo #endif>> $(GD_CONFIG_H) @@ -201,6 +207,9 @@ make_dirs: @echo #ifndef HAVE_LIBHEIF>> $(GD_CONFIG_H) @echo #define HAVE_LIBHEIF>> $(GD_CONFIG_H) @echo #endif>> $(GD_CONFIG_H) + @echo #ifndef HAVE_LIBAVIF>> $(GD_CONFIG_H) + @echo #define HAVE_LIBAVIF>> $(GD_CONFIG_H) + @echo #endif>> $(GD_CONFIG_H) @echo #ifndef HAVE_LIBZ>> $(GD_CONFIG_H) @echo #define HAVE_LIBZ>> $(GD_CONFIG_H) @echo #endif>> $(GD_CONFIG_H) diff --git a/windows/Makefiletest.vc b/windows/Makefiletest.vc index 827a4e7..6e5d598 100644 --- a/windows/Makefiletest.vc +++ b/windows/Makefiletest.vc @@ -1,5 +1,10 @@ TESTS=bmp\bmp_im2im \ bmp\bmp_null \ +avif\avif_ptr_double_free \ +avif\avif_im2im \ +avif\avif_null \ +avif\compare_avif_to_png \ +avif\bad_input \ freetype\bug00132 \ gd\gd_im2im \ gd\gd_null \ diff --git a/windows/msys/Makefile b/windows/msys/Makefile index 8c5d380..d183ac2 100644 --- a/windows/msys/Makefile +++ b/windows/msys/Makefile @@ -98,7 +98,8 @@ gd_topal.c gd_wbmp.c gdcache.c gdfontg.c gdfontl.c gdfontmb.c \ gdfonts.c gdfontt.c gdft.c gdhelpers.c gdkanji.c gdtables.c gdxpm.c \ wbmp.c gd_filter.c gd_nnquant.c gd_rotate.c gd_matrix.c \ gd_interpolation.c gd_crop.c gd_webp.c gd_heif.c gd_tiff.c gd_tga.c \ -gd_bmp.c gd_xbm.c gd_color_match.c gd_version.c gd_filename.c +gd_bmp.c gd_xbm.c gd_color_match.c gd_version.c gd_filename.c \ +gd_avif.c OBJ=$(SRC:.c=.o) -- cgit v1.2.1