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:
parent
19a838470b
commit
ad7ddc4f24
@ -6,6 +6,8 @@
|
|||||||
* - add the fancier algorithm from vipsthumbnail
|
* - add the fancier algorithm from vipsthumbnail
|
||||||
* 11/11/15
|
* 11/11/15
|
||||||
* - smarter cache sizing
|
* - 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 window_size;
|
||||||
int int_hshrink;
|
int int_hshrink;
|
||||||
int int_vshrink;
|
int int_vshrink;
|
||||||
int int_shrink_width;
|
|
||||||
int int_shrink_height;
|
|
||||||
double hresidual;
|
double hresidual;
|
||||||
double vresidual;
|
double vresidual;
|
||||||
double sigma;
|
double sigma;
|
||||||
@ -128,22 +128,25 @@ vips_resize_build( VipsObject *object )
|
|||||||
int_vshrink = resize->vscale > 1.0 ?
|
int_vshrink = resize->vscale > 1.0 ?
|
||||||
1 : VIPS_FLOOR( 1.0 / resize->vscale );
|
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,
|
||||||
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,
|
||||||
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;
|
if( (in->Xsize * resize->scale) / (in->Xsize / int_hshrink) > 0.9 )
|
||||||
int_shrink_height = in->Ysize / int_vshrink;
|
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;
|
hresidual = (in->Xsize * resize->scale) / (in->Xsize / int_hshrink);
|
||||||
vresidual = (in->Ysize * resize->vscale) / int_shrink_height;
|
vresidual = (in->Ysize * resize->vscale) / (in->Ysize / int_vshrink);
|
||||||
|
|
||||||
/* A copy for enlarge resize.
|
/* A copy for enlarge resize.
|
||||||
*/
|
*/
|
||||||
|
@ -75,6 +75,8 @@
|
|||||||
* - add SVG --size support
|
* - add SVG --size support
|
||||||
* 28/2/16
|
* 28/2/16
|
||||||
* - add webp --shrink support
|
* - 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
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -221,14 +223,11 @@ thumbnail_find_jpegshrink( VipsImage *im )
|
|||||||
if( linear_processing )
|
if( linear_processing )
|
||||||
return( 1 );
|
return( 1 );
|
||||||
|
|
||||||
/* We want to leave a bit of shrinking for our interpolator, we don't
|
if( shrink >= 8 )
|
||||||
* want to do all the shrinking with libjpeg.
|
|
||||||
*/
|
|
||||||
if( shrink >= 16 )
|
|
||||||
return( 8 );
|
return( 8 );
|
||||||
else if( shrink >= 8 )
|
|
||||||
return( 4 );
|
|
||||||
else if( shrink >= 4 )
|
else if( shrink >= 4 )
|
||||||
|
return( 4 );
|
||||||
|
else if( shrink >= 2 )
|
||||||
return( 2 );
|
return( 2 );
|
||||||
else
|
else
|
||||||
return( 1 );
|
return( 1 );
|
||||||
|
Loading…
Reference in New Issue
Block a user