more vips_resize() tuning

now we have better tuning for the anti-alias blur, we can increase the
amount we shrink by and reduce the amount we affine by

this gives a noticable speedup
This commit is contained in:
John Cupitt 2016-03-01 11:19:30 +00:00
parent 19a838470b
commit ad7ddc4f24
2 changed files with 19 additions and 17 deletions

View File

@ -6,6 +6,8 @@
* - add the fancier algorithm from vipsthumbnail
* 11/11/15
* - smarter cache sizing
* 29/2/16
* - shrink more affine less, now we have better anti-alias settings
*/
/*
@ -87,8 +89,6 @@ vips_resize_build( VipsObject *object )
int window_size;
int int_hshrink;
int int_vshrink;
int int_shrink_width;
int int_shrink_height;
double hresidual;
double vresidual;
double sigma;
@ -128,22 +128,25 @@ vips_resize_build( VipsObject *object )
int_vshrink = resize->vscale > 1.0 ?
1 : VIPS_FLOOR( 1.0 / resize->vscale );
/* We want to shrink by less for interpolators with larger windows.
/* We want to shrink by less for interpolators with large windows.
*/
int_hshrink = VIPS_MAX( 1,
int_hshrink / VIPS_MAX( 1, window_size / 2 ) );
int_hshrink / VIPS_MAX( 1, window_size / 3 ) );
int_vshrink = VIPS_MAX( 1,
int_vshrink / VIPS_MAX( 1, window_size / 2 ) );
int_vshrink / VIPS_MAX( 1, window_size / 3 ) );
/* Size after int shrink.
/* Will this produce a residual scale of almost 1? shrink a bit less
* if it will.
*/
int_shrink_width = in->Xsize / int_hshrink;
int_shrink_height = in->Ysize / int_vshrink;
if( (in->Xsize * resize->scale) / (in->Xsize / int_hshrink) > 0.9 )
int_hshrink = VIPS_MAX( 1, int_hshrink - 1 );
if( (in->Ysize * resize->vscale) / (in->Ysize / int_vshrink) > 0.9 )
int_vshrink = VIPS_MAX( 1, int_vshrink - 1 );
/* Therefore residual scale factor is.
/* Residual scale factor is.
*/
hresidual = (in->Xsize * resize->scale) / int_shrink_width;
vresidual = (in->Ysize * resize->vscale) / int_shrink_height;
hresidual = (in->Xsize * resize->scale) / (in->Xsize / int_hshrink);
vresidual = (in->Ysize * resize->vscale) / (in->Ysize / int_vshrink);
/* A copy for enlarge resize.
*/

View File

@ -75,6 +75,8 @@
* - add SVG --size support
* 28/2/16
* - add webp --shrink support
* 29/2/16
* - make more use of jpeg shrink-on-load now we've tuned vips_resize()
*/
#ifdef HAVE_CONFIG_H
@ -221,14 +223,11 @@ thumbnail_find_jpegshrink( VipsImage *im )
if( linear_processing )
return( 1 );
/* We want to leave a bit of shrinking for our interpolator, we don't
* want to do all the shrinking with libjpeg.
*/
if( shrink >= 16 )
if( shrink >= 8 )
return( 8 );
else if( shrink >= 8 )
return( 4 );
else if( shrink >= 4 )
return( 4 );
else if( shrink >= 2 )
return( 2 );
else
return( 1 );