From 0c6da0c330d5251bc176f4d922be76237b2ed16f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 8 Apr 2013 13:08:24 +0100 Subject: [PATCH] fix demand hints for shrink "vips shrink" was broken due to wonky demand hints, thanks Jan --- ChangeLog | 1 + libvips/foreign/jpeg2vips.c | 2 +- libvips/foreign/vipspng.c | 5 +++-- libvips/iofuncs/generate.c | 1 + libvips/iofuncs/image.c | 4 +++- libvips/resample/shrink.c | 8 +++++--- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c84cef7..4a024933 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 12/3/13 started 7.32.2 - removed some left-over debugging code from configure.ac - better error messages from vips.c +- fix demand hints so "vips shrink" works again, thanks Jan 6/2/13 started 7.32.1 - fix --without-lcms, thanks speckins diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index 24338a8c..84c90d8b 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -746,7 +746,7 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out ) interpretation, xres, yres ); - vips_demand_hint( out, VIPS_DEMAND_STYLE_FATSTRIP, NULL ); + vips_demand_hint( out, VIPS_DEMAND_STYLE_THINSTRIP, NULL ); /* Interlaced jpegs need lots of memory to read, so our caller needs * to know. diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index 5416c184..99929cda 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -318,9 +318,10 @@ png2vips_header( Read *read, VipsImage *out ) VIPS_CODING_NONE, interpretation, Xres, Yres ); - /* We're always supposed to set dhint. + /* Sequential mode needs thinstrip to work with things like + * vips_shrink(). */ - vips_demand_hint( out, VIPS_DEMAND_STYLE_FATSTRIP, NULL ); + vips_demand_hint( out, VIPS_DEMAND_STYLE_THINSTRIP, NULL ); /* Fetch the ICC profile. @name is useless, something like "icc" or * "ICC Profile" etc. Ignore it. diff --git a/libvips/iofuncs/generate.c b/libvips/iofuncs/generate.c index 38990d10..05e28bd3 100644 --- a/libvips/iofuncs/generate.c +++ b/libvips/iofuncs/generate.c @@ -84,6 +84,7 @@ /* #define VIPS_DEBUG +#define DEBUG */ #ifdef HAVE_CONFIG_H diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index 59320d8f..031fc653 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -539,8 +539,10 @@ vips_image_preeval_cb( VipsImage *image, VipsProgress *progress, int *last ) vips_get_tile_size( image, &tile_width, &tile_height, &nlines ); - printf( _( "%s %s: %d threads, %d x %d tiles, groups of %d scanlines" ), + printf( _( "%s %s: %d x %d pixels, %d threads, %d x %d tiles, " + "%d lines in buffer" ), g_get_prgname(), image->filename, + image->Xsize, image->Ysize, vips_concurrency_get(), tile_width, tile_height, nlines ); printf( "\n" ); diff --git a/libvips/resample/shrink.c b/libvips/resample/shrink.c index 4e43b538..22f984a0 100644 --- a/libvips/resample/shrink.c +++ b/libvips/resample/shrink.c @@ -36,6 +36,8 @@ * - some tuning .. tried an int coordinate path, not worthwhile * 16/11/12 * - don't change xres/yres, see comment below + * 8/4/13 + * - oops demand_hint was incorrect, thanks Jan */ /* @@ -331,12 +333,12 @@ vips_shrink_build( VipsObject *object ) if( vips_image_copy_fields( resample->out, resample->in ) ) return( -1 ); - /* THINSTRIP will work, FATSTRIP will break seq mode. If you combine - * shrink with conv you'll need to use a line cache to maintain + /* THINSTRIP will work, anything else will break seq mode. If you + * combine shrink with conv you'll need to use a line cache to maintain * sequentiality. */ vips_demand_hint( resample->out, - VIPS_DEMAND_STYLE_ANY, resample->in, NULL ); + VIPS_DEMAND_STYLE_THINSTRIP, resample->in, NULL ); /* Size output. Note: we round the output width down! *