Merge branch '8.11'

This commit is contained in:
John Cupitt 2021-07-02 17:20:21 +01:00
commit d14d5eed25
4 changed files with 86 additions and 36 deletions

View File

@ -18,7 +18,6 @@ EXTRA_DIST = \
depcomp \
README.md
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = vips.pc vips-cpp.pc
dist-hook:

View File

@ -246,6 +246,20 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
ALL_LINGUAS="en_GB de"
AM_GLIB_GNU_GETTEXT
# Compatibility with pkg.m4 < 0.27
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
[AC_ARG_WITH([pkgconfigdir],
[AS_HELP_STRING([--with-pkgconfigdir],
[install directory for *.pc pkg-config file])],
[],[with_pkgconfigdir='$(libdir)/pkgconfig'])
AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
# Compatibility with pkg.m4 < 0.28
m4_define_default([PKG_CHECK_VAR],
[AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])
AS_IF([test -z "$$1"], [$1=`$PKG_CONFIG --variable="$3" "$2"`])
AS_IF([test -n "$$1"], [$4], [$5])])
# we need to disable some features on some known-bad gcc versions
# these will be "" for clang etc.
#
@ -433,22 +447,21 @@ AC_ARG_ENABLE([modules],
[enable_modules="$enableval"],
[enable_modules="$enable_modules_default"])
gmodule_supported_bool=false
gmodule_supported_flag=no
gmodule_with_flag=yes
if test x"$enable_modules" = x"no"; then
AC_MSG_RESULT(no)
AC_MSG_RESULT([no])
else
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(whether dynamic modules work)
gmodule_supported_bool=`$PKG_CONFIG gmodule-no-export-2.0 --variable gmodule_supported`
if $gmodule_supported_bool; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([whether dynamic modules work])
PKG_CHECK_VAR([gmodule_supported], [gmodule-no-export-2.0], [gmodule_supported])
if test x"$gmodule_supported" = x"true"; then
gmodule_supported_flag=yes
gmodule_with_flag='module'
AC_MSG_RESULT(yes)
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT(no)
AC_MSG_RESULT([no])
fi
fi
@ -869,16 +882,16 @@ AS_IF([test x"$with_heif" = x"module"],
if test x"$with_heif" != x"no"; then
PKG_CHECK_MODULES(HEIF, libheif >= 1.3.0,
[with_heif=yes
have_h265_decoder=`$PKG_CONFIG libheif --variable builtin_h265_decoder`
have_avif_decoder=`$PKG_CONFIG libheif --variable builtin_avif_decoder`
PKG_CHECK_VAR([have_h265_decoder], [libheif], [builtin_h265_decoder])
PKG_CHECK_VAR([have_avif_decoder], [libheif], [builtin_avif_decoder])
# test for !=no so that we work for older libheif which does not have
# this variable
if test x"$have_h265_decoder" != x"no" -o x"$have_avif_decoder" = x"yes"; then
AC_DEFINE(HAVE_HEIF_DECODER,1,
[define if your libheif has decode support.])
fi
have_h265_encoder=`$PKG_CONFIG libheif --variable builtin_h265_encoder`
have_avif_encoder=`$PKG_CONFIG libheif --variable builtin_avif_encoder`
PKG_CHECK_VAR([have_h265_encoder], [libheif], [builtin_h265_encoder])
PKG_CHECK_VAR([have_avif_encoder], [libheif], [builtin_avif_encoder])
if test x"$have_h265_encoder" != x"no" -o x"$have_avif_encoder" = x"yes"; then
AC_DEFINE(HAVE_HEIF_ENCODER,1,
[define if your libheif has encode support.])
@ -887,7 +900,6 @@ if test x"$with_heif" != x"no"; then
[PACKAGES_USED="$PACKAGES_USED libheif"])
],
[AC_MSG_WARN([libheif >= 1.3.0 not found; disabling HEIF support])
pkg-config --exists --print-errors "libheif >= 1.3.0"
with_heif=no
with_heif_module=no
have_h265_decoder=

View File

@ -1907,6 +1907,62 @@ write_strip( VipsRegion *region, VipsRect *area, void *a )
#define CopyField( tag, v ) \
if( TIFFGetField( in, tag, &v ) ) TIFFSetField( out, tag, v )
static int
wtiff_copy_tiles( Wtiff *wtiff, TIFF *out, TIFF *in )
{
const ttile_t n_tiles = TIFFNumberOfTiles( in );
tsize_t tile_size;
tdata_t buf;
ttile_t i;
if( wtiff->compression == COMPRESSION_JPEG )
tile_size = TIFFTileSize( in );
else
/* If we will be copying raw tiles we need a buffer large
* enough to hold the largest compressed tile in any page.
*
* Allocate a buffer 2x the uncompressed tile size ... much
* simpler than searching every page for the largest tile with
* TIFFTAG_TILEBYTECOUNTS.
*/
tile_size = 2 * wtiff->tls * wtiff->tileh;
buf = vips_malloc( NULL, tile_size );
for( i = 0; i < n_tiles; i++ ) {
tsize_t len;
/* If this is a JPEG-compressed TIFF, we need to decompress
* and recompress, since tiles are actually written in several
* places (coefficients go in the tile, huffman tables go
* elsewhere).
*
* For all other compression types, we can just use
* TIFFReadRawTile()/TIFFWriteRawTile().
*/
if( wtiff->compression == COMPRESSION_JPEG ) {
len = TIFFReadEncodedTile( in, i, buf, tile_size );
if( len <= 0 ||
TIFFWriteEncodedTile( out, i, buf, len ) < 0 ) {
g_free( buf );
return( -1 );
}
}
else {
len = TIFFReadRawTile( in, i, buf, tile_size );
if( len <= 0 ||
TIFFWriteRawTile( out, i, buf, len ) < 0 ) {
g_free( buf );
return( -1 );
}
}
}
g_free( buf );
return( 0 );
}
/* Copy a TIFF file ... we know we wrote it, so just copy the tags we know
* we might have set.
*/
@ -1917,9 +1973,6 @@ wtiff_copy_tiff( Wtiff *wtiff, TIFF *out, TIFF *in )
uint16 ui16;
uint16 ui16_2;
float f;
tdata_t buf;
ttile_t tile_no;
ttile_t n;
uint16 *a;
/* All the fields we might have set.
@ -2004,24 +2057,8 @@ wtiff_copy_tiff( Wtiff *wtiff, TIFF *out, TIFF *in )
wtiff_embed_imagedescription( wtiff, out ) )
return( -1 );
buf = vips_malloc( NULL, TIFFTileSize( in ) );
n = TIFFNumberOfTiles( in );
for( tile_no = 0; tile_no < n; tile_no++ ) {
tsize_t len;
/* TIFFReadRawTile()/TIFFWriteRawTile() would save us
* decompress/recompress, but they won't work for
* JPEG-compressed tiles since they won't copy the
* JPEG quant tables we need.
*/
len = TIFFReadEncodedTile( in, tile_no, buf, -1 );
if( len < 0 ||
TIFFWriteEncodedTile( out, tile_no, buf, len ) < 0 ) {
g_free( buf );
return( -1 );
}
}
g_free( buf );
if( wtiff_copy_tiles( wtiff, out, in ) )
return( -1 );
return( 0 );
}

View File

@ -1217,10 +1217,12 @@ vips_guess_libdir( const char *argv0, const char *env_name )
*
* The lib directory name can be eg. "lib", "lib64" etc. depending on
* the platform, so copy that from the configure-time libdir if we can.
* The configure-time LIBDIR is generated by autotools and always uses
* '/', even on Windows.
*/
if( strcmp( prefix, VIPS_PREFIX ) == 0 )
libdir = VIPS_LIBDIR;
else if( (suffix = strrchr( VIPS_LIBDIR, G_DIR_SEPARATOR )) )
else if( (suffix = strrchr( VIPS_LIBDIR, '/' )) )
libdir = g_strdup_printf( "%s%s", prefix, suffix );
else
libdir = g_strdup_printf( "%s/lib", prefix );