From 9febc3ac3e481b4607f58902dc511b06beed9d03 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 31 Dec 2017 12:56:11 +0000 Subject: [PATCH] seq could be set on small random images images under the disc threshold opened in random access mode from sequential loaders would have the seq tag set on them, causing performance problems with vips_resize() see https://github.com/jcupitt/libvips/issues/840 --- ChangeLog | 1 + libvips/foreign/foreign.c | 9 ++++++++- libvips/iofuncs/image.c | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 100d044a..8b2f64ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ - bump wrapper script version [bgilbert] - fix a memleak on error during jpeg buffer write [lovell] - fix misspelling of IPTC as IPCT [lovell] +- seq could be set on small images opened in random-access mode [aferrero2707] 15/4/17 started 8.6.0 - supports fits images with leading non-image HDUs, thanks benepo diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 0c310f9b..2ab56060 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -838,7 +838,6 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b ) */ vips_image_pipelinev( load->out, load->out->dhint, load->real, NULL ); - } return( vips_region_new( load->real ) ); @@ -951,6 +950,14 @@ vips_foreign_load_build( VipsObject *object ) vips_stop_one, NULL, load ) ) return( -1 ); + + /* We have delayed load. This must mean that the loader will + * load to a memory buffer or temp file, and will therefore + * support random access. + * + * Make sure there's no seq flag set on the output image. + */ + (void) vips_image_remove( load->out, VIPS_META_SEQUENTIAL ); } return( 0 ); diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index ff434a4b..827ca99a 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -3139,7 +3139,8 @@ vips_image_copy_memory( VipsImage *image ) * image might have been shared, use the less efficient * vips_image_copy_memory() instead. * - * See also: vips_image_copy_memory(), vips_image_pio_input(), vips_image_inplace(), VIPS_IMAGE_ADDR(). + * See also: vips_image_copy_memory(), vips_image_pio_input(), + * vips_image_inplace(), VIPS_IMAGE_ADDR(). * * Returns: 0 on succeess, or -1 on error. */