fix heifload with libheif 1.6

heif_avif wasn't added until libheif 1.7
This commit is contained in:
John Cupitt 2020-10-11 19:54:36 +01:00
parent 8d4852f217
commit 888b5654a0
2 changed files with 16 additions and 15 deletions

View File

@ -888,16 +888,13 @@ if test x"$with_heif" = x"yes"; then
LIBS="$save_LIBS" LIBS="$save_LIBS"
fi fi
# heif_main_brand added in 1.4.0 # heif_main_brand added in 1.4.0, but heif_avif appeared in 1.7 ... just check
# the libheif version number since testing for enums is annoying
if test x"$with_heif" = x"yes"; then if test x"$with_heif" = x"yes"; then
save_LIBS="$LIBS" PKG_CHECK_MODULES(HEIF_AVIF, libheif >= 1.7.0, [
LIBS="$LIBS $HEIF_LIBS" AC_DEFINE(HAVE_HEIF_AVIF,1,[define if you have heif_avif.])
AC_CHECK_FUNCS(heif_main_brand,[ ], [
AC_DEFINE(HAVE_HEIF_MAIN_BRAND,1, ])
[define if you have heif_main_brand.])
],[]
)
LIBS="$save_LIBS"
fi fi
# heif_decoding_options.convert_hdr_to_8bit added in 1.7.0 # heif_decoding_options.convert_hdr_to_8bit added in 1.7.0

View File

@ -567,20 +567,24 @@ vips_foreign_load_heif_set_header( VipsForeignLoadHeif *heif, VipsImage *out )
vips_image_set_int( out, vips_image_set_int( out,
VIPS_META_PAGE_HEIGHT, heif->page_height ); VIPS_META_PAGE_HEIGHT, heif->page_height );
/* Determine compression from HEIF "brand" /* Determine compression from HEIF "brand". heif_avif and heif_avis
* Requires libheif 1.4.0+, prior versions were HEVC only * were added in v1.7.
*/ */
compression = VIPS_FOREIGN_HEIF_COMPRESSION_HEVC; compression = VIPS_FOREIGN_HEIF_COMPRESSION_HEVC;
#ifdef HAVE_HEIF_MAIN_BRAND #ifdef HAVE_HEIF_AVIF
{
const unsigned char *brand_data; const unsigned char *brand_data;
if ( brand_data = vips_source_sniff( heif->source, 12 ) ) {
if( (brand_data = vips_source_sniff( heif->source, 12 )) ) {
enum heif_brand brand; enum heif_brand brand;
brand = heif_main_brand( brand_data, 12 ); brand = heif_main_brand( brand_data, 12 );
if( brand == heif_avif || brand == heif_avis ) if( brand == heif_avif ||
brand == heif_avis )
compression = VIPS_FOREIGN_HEIF_COMPRESSION_AV1; compression = VIPS_FOREIGN_HEIF_COMPRESSION_AV1;
} }
#endif /*HAVE_HEIF_MAIN_BRAND*/ }
#endif /*HAVE_HEIF_AVIF*/
vips_image_set_string( out, "heif-compression", vips_image_set_string( out, "heif-compression",
vips_enum_nick( VIPS_TYPE_FOREIGN_HEIF_COMPRESSION, vips_enum_nick( VIPS_TYPE_FOREIGN_HEIF_COMPRESSION,