From 46a18118c6b17666d2a84cc9f76a37f97e635049 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 15 Mar 2016 16:46:18 +0000 Subject: [PATCH] works! --- ChangeLog | 4 +-- libvips/resample/reduceh.cpp | 4 +-- libvips/resample/reducev.cpp | 4 +-- libvips/resample/resize.c | 65 ------------------------------------ 4 files changed, 4 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9113411b..1c9a2ff9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ 29/1/16 started 8.3 - add vips_reduce*() ... a fast path for affine downsize -- vips_resize() uses vips_reduce() with lanczos3 and better anti-alias +- vips_resize() uses vips_reduce() with lanczos3 - bicubic is better on 32-bit int images - add pdfload, svgload, gifload for PDF, SVG and GIF rendering - vipsthumbnail knows about pdfload and svgload @@ -17,7 +17,7 @@ - vipsthumbnail knows about webp shrink-on-load - better behaviour for vips_cast() shift of non-int types (thanks apacheark) - python .bandrank() now works like .bandjoin() -- vipsthumbnail --interpolator and --sharpen are deprecated +- vipsthumbnail --interpolator and --sharpen switches are deprecated - switches to disable PPM, Rad and Analyze support 27/1/16 started 8.2.3 diff --git a/libvips/resample/reduceh.cpp b/libvips/resample/reduceh.cpp index 1c009a10..a32412c5 100644 --- a/libvips/resample/reduceh.cpp +++ b/libvips/resample/reduceh.cpp @@ -469,9 +469,6 @@ vips_reduceh_build( VipsObject *object ) "%s", _( "reduce factors should be >= 1" ) ); return( -1 ); } - if( reduceh->xshrink > 3 ) - vips_warn( object_class->nickname, - "%s", _( "reduce factor greater than 3" ) ); if( reduceh->xshrink == 1 ) return( vips_image_write( in, resample->out ) ); @@ -480,6 +477,7 @@ vips_reduceh_build( VipsObject *object ) */ reduceh->n_points = vips_reduce_get_points( reduceh->kernel, reduceh->xshrink ); + vips_info( object_class->nickname, "%d point mask", reduceh->n_points ); if( reduceh->n_points > MAX_POINTS ) { vips_error( object_class->nickname, "%s", _( "reduce factor too large" ) ); diff --git a/libvips/resample/reducev.cpp b/libvips/resample/reducev.cpp index b865f1c1..9fd2f263 100644 --- a/libvips/resample/reducev.cpp +++ b/libvips/resample/reducev.cpp @@ -378,9 +378,6 @@ vips_reducev_build( VipsObject *object ) "%s", _( "reduce factor should be >= 1" ) ); return( -1 ); } - if( reducev->yshrink > 3 ) - vips_warn( object_class->nickname, - "%s", _( "reduce factor greater than 3" ) ); if( reducev->yshrink == 1 ) return( vips_image_write( in, resample->out ) ); @@ -394,6 +391,7 @@ vips_reducev_build( VipsObject *object ) "%s", _( "reduce factor too large" ) ); return( -1 ); } + vips_info( object_class->nickname, "%d point mask", reducev->n_points ); for( int y = 0; y < VIPS_TRANSFORM_SCALE + 1; y++ ) { reducev->matrixf[y] = VIPS_ARRAY( object, reducev->n_points, double ); diff --git a/libvips/resample/resize.c b/libvips/resample/resize.c index bb36f5be..b77b587c 100644 --- a/libvips/resample/resize.c +++ b/libvips/resample/resize.c @@ -150,56 +150,6 @@ vips_resize_build( VipsObject *object ) hresidual = (double) target_width / in->Xsize; vresidual = (double) target_height / in->Ysize; - /* We want to make sure we read the image sequentially. - * However, the convolution we may be doing later will force us - * into SMALLTILE or maybe FATSTRIP mode and that will break - * sequentiality. - * - * So ... read into a cache where tiles are scanlines, and make sure - * we keep enough scanlines. - * - * We use a threaded tilecache to avoid a deadlock: suppose thread1, - * evaluating the top block of the output, is delayed, and thread2, - * evaluating the second block, gets here first (this can happen on - * a heavily-loaded system). - * - * With an unthreaded tilecache, thread2 will get - * the cache lock and start evaling the second block of the shrink. - * When it reaches the png reader it will stall until the first block - * has been used ... but it never will, since thread1 will block on - * this cache lock. - * - * Cache sizing: we double-buffer writes, so threads can be up to one - * line of tiles behind. For example, one thread could be allocated - * tile (0,0) and then stall, the whole write system won't stall until - * it tries to allocate tile (0, 2). - * - * We reduce down after this, which can be a scale of up to @residual, - * perhaps 0.5 or down as low as 0.3 depending on the interpolator. So - * the number of scanlines we need to keep for the worst case is - * 2 * @tile_height / @residual, plus a little extra. - */ - if( int_vshrink > 1 ) { - int tile_width; - int tile_height; - int n_lines; - - int need_lines; - - vips_get_tile_size( in, - &tile_width, &tile_height, &n_lines ); - need_lines = 1.2 * n_lines / vresidual; - if( vips_tilecache( in, &t[6], - "tile_width", in->Xsize, - "tile_height", 10, - "max_tiles", 1 + need_lines / 10, - "access", VIPS_ACCESS_SEQUENTIAL, - "threaded", TRUE, - NULL ) ) - return( -1 ); - in = t[6]; - } - /* Any downsizing. */ if( hresidual < 1.0 || @@ -226,21 +176,6 @@ vips_resize_build( VipsObject *object ) in = t[3]; } - /* If we are upsizing, don't sharpen. - */ - if( int_hshrink >= 1 ) { - vips_info( class->nickname, "final sharpen" ); - t[4] = vips_image_new_matrixv( 3, 3, - -1.0, -1.0, -1.0, - -1.0, 32.0, -1.0, - -1.0, -1.0, -1.0 ); - vips_image_set_double( t[4], "scale", 24 ); - - if( vips_conv( in, &t[5], t[4], NULL ) ) - return( -1 ); - in = t[5]; - } - if( vips_image_write( in, resample->out ) ) return( -1 );