From 694d86e5c514bcc444b07800c895e30cf95c7f3a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 21 Aug 2014 13:05:29 +0100 Subject: [PATCH 1/5] fix vipsthumbnail on very-many-core systems see: https://github.com/jcupitt/libvips/issues/160 we were using UNBUFFERED, but on very-many-core systems this can get out of order enough to make vipspng free the read object early --- ChangeLog | 1 + tools/vipsthumbnail.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 05a971dc..f278b1df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ - fix similarity rotate+scale, thanks Topochicho - fix 16-bit PNG save, thanks John - fix dzsave date on Windows, thanks John +- fix vipsthumbnail on many-core systems, thanks James 25/7/14 started 7.40.5 - fix a race in im_maxpos_avg() diff --git a/tools/vipsthumbnail.c b/tools/vipsthumbnail.c index d4a66e3f..cb250fc2 100644 --- a/tools/vipsthumbnail.c +++ b/tools/vipsthumbnail.c @@ -318,8 +318,10 @@ thumbnail_open( VipsObject *process, const char *filename ) "loading jpeg with factor %d pre-shrink", jpegshrink ); + /* We can't use UNBUFERRED safely on very-many-core systems. + */ if( !(im = vips_image_new_from_file( filename, - "access", VIPS_ACCESS_SEQUENTIAL_UNBUFFERED, + "access", VIPS_ACCESS_SEQUENTIAL, "shrink", jpegshrink, NULL )) ) return( NULL ); @@ -328,7 +330,7 @@ thumbnail_open( VipsObject *process, const char *filename ) /* All other formats. */ if( !(im = vips_image_new_from_file( filename, - "access", VIPS_ACCESS_SEQUENTIAL_UNBUFFERED, + "access", VIPS_ACCESS_SEQUENTIAL, NULL )) ) return( NULL ); } From 04692c29ddf194d66c847e2476fb43bdf2e937e5 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 21 Aug 2014 15:14:26 +0100 Subject: [PATCH 2/5] enlarge the buffered tilecache helps vipsthumbnail under load --- libvips/conversion/tilecache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvips/conversion/tilecache.c b/libvips/conversion/tilecache.c index 69c88487..9530db3a 100644 --- a/libvips/conversion/tilecache.c +++ b/libvips/conversion/tilecache.c @@ -941,7 +941,7 @@ vips_line_cache_build( VipsObject *object ) vips_get_tile_size( block_cache->in, &tile_width, &tile_height, &nlines ); - block_cache->max_tiles = 3 * + block_cache->max_tiles = 4 * (1 + nlines / block_cache->tile_height); VIPS_DEBUG_MSG( "vips_line_cache_build: nlines = %d\n", From a75ddfbd5a35547a8fae7b5e10896f6ba41797d7 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 21 Aug 2014 22:01:40 +0100 Subject: [PATCH 3/5] fix matlab load oops, width and height were swapped --- ChangeLog | 3 +++ configure.ac | 6 +++--- libvips/foreign/matlab.c | 35 ++++++++++++++++++++++++++++------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f278b1df..64a931c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +21/8/14 started 7.40.7 +- fix matlab load + 12/8/14 started 7.40.6 - more doc fixes - fix similarity rotate+scale, thanks Topochicho diff --git a/configure.ac b/configure.ac index 99f05c92..6e02fca9 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [7.40.6], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [7.40.7], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [7]) m4_define([vips_minor_version], [40]) -m4_define([vips_micro_version], [6]) +m4_define([vips_micro_version], [7]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date` # binary interface changes not backwards compatible?: reset age to 0 LIBRARY_CURRENT=38 -LIBRARY_REVISION=4 +LIBRARY_REVISION=5 LIBRARY_AGE=0 # patched into include/vips/version.h diff --git a/libvips/foreign/matlab.c b/libvips/foreign/matlab.c index fce0b5ee..a0f06a82 100644 --- a/libvips/foreign/matlab.c +++ b/libvips/foreign/matlab.c @@ -4,6 +4,9 @@ * - transpose on load, assemble planes into bands (thanks Mikhail) * 20/12/11 * - reworked as some fns ready for new-style classes + * 21/8/14 + * - swap width/height + * - set interpretation to rgb16 etc. */ /* @@ -150,6 +153,28 @@ static int mat2vips_formats[][2] = { { MAT_C_DOUBLE, VIPS_FORMAT_DOUBLE } }; +/* Pick an interpretation. + */ +static VipsInterpretation +mat2vips_pick_interpretation( int bands, VipsBandFormat format ) +{ + if( bands == 3 && + vips_band_format_is8bit( format ) ) + return( VIPS_INTERPRETATION_sRGB ); + if( bands == 3 && + (format == VIPS_FORMAT_USHORT || + format == VIPS_FORMAT_SHORT) ) + return( VIPS_INTERPRETATION_RGB16 ); + if( bands == 1 && + (format == VIPS_FORMAT_USHORT || + format == VIPS_FORMAT_SHORT) ) + return( VIPS_INTERPRETATION_GREY16 ); + if( bands > 1 ) + return( VIPS_INTERPRETATION_MULTIBAND ); + + return( VIPS_INTERPRETATION_MULTIBAND ); +} + static int mat2vips_get_header( matvar_t *var, VipsImage *im ) { @@ -165,10 +190,10 @@ mat2vips_get_header( matvar_t *var, VipsImage *im ) bands = var->dims[2]; case 2: - height = var->dims[1]; + width = var->dims[1]; case 1: - width = var->dims[0]; + height = var->dims[0]; break; default: @@ -177,11 +202,6 @@ mat2vips_get_header( matvar_t *var, VipsImage *im ) return( -1 ); } - if( bands > 1 ) - interpretation = VIPS_INTERPRETATION_MULTIBAND; - else - interpretation = VIPS_INTERPRETATION_B_W; - for( i = 0; i < VIPS_NUMBER( mat2vips_formats ); i++ ) if( mat2vips_formats[i][0] == var->class_type ) break; @@ -191,6 +211,7 @@ mat2vips_get_header( matvar_t *var, VipsImage *im ) return( -1 ); } format = mat2vips_formats[i][1]; + interpretation = mat2vips_pick_interpretation( bands, format ); vips_image_init_fields( im, width, height, bands, From 30aae507a3e3c533eb75f163bf21d76f48e1c356 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 26 Aug 2014 17:07:44 +0100 Subject: [PATCH 4/5] fix memleak in tilecache --- ChangeLog | 1 + libvips/conversion/tilecache.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 64a931c5..4ac51ca8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 21/8/14 started 7.40.7 - fix matlab load +- fix memleak in tilecache [Lovell] 12/8/14 started 7.40.6 - more doc fixes diff --git a/libvips/conversion/tilecache.c b/libvips/conversion/tilecache.c index 9530db3a..1634cdf1 100644 --- a/libvips/conversion/tilecache.c +++ b/libvips/conversion/tilecache.c @@ -29,6 +29,8 @@ * - could deadlock if downstream raised an error (thanks Todd) * 25/4/13 * - cache minimisation is optional, see "persistent" flag + * 26/8/14 Lovell + * - free the hash table in _dispose() */ /* @@ -156,6 +158,10 @@ vips_block_cache_dispose( GObject *gobject ) VIPS_FREEF( vips_g_mutex_free, cache->lock ); VIPS_FREEF( vips_g_cond_free, cache->new_tile ); + if( cache->tiles ) + g_assert( g_hash_table_size( cache->tiles ) == 0 ); + VIPS_FREEF( g_hash_table_destroy, cache->tiles ); + G_OBJECT_CLASS( vips_block_cache_parent_class )->dispose( gobject ); } From 86b729150c300d9b6914fa9823a255268f80f8e5 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 27 Aug 2014 13:46:51 +0100 Subject: [PATCH 5/5] fix memleak in type.c see https://github.com/jcupitt/libvips/pull/164 --- ChangeLog | 1 + libvips/iofuncs/type.c | 1 + 2 files changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4ac51ca8..b63a1b8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 21/8/14 started 7.40.7 - fix matlab load - fix memleak in tilecache [Lovell] +- fix memleak in VipsArray [Lovell] 12/8/14 started 7.40.6 - more doc fixes diff --git a/libvips/iofuncs/type.c b/libvips/iofuncs/type.c index 8206dd71..897f55cc 100644 --- a/libvips/iofuncs/type.c +++ b/libvips/iofuncs/type.c @@ -334,6 +334,7 @@ vips_area_free_array_object( GObject **array, VipsArea *area ) for( i = 0; i < area->n; i++ ) VIPS_FREEF( g_object_unref, array[i] ); + VIPS_FREE( array ); area->n = 0; }