more careful p->t conversion

When we convert an image from "p" to "t" in vips_image_wio_input(), zap
start/gen/stop callbacks. This makes vips_region_prepare_to() read from
the "t" rather than trying to gen pixels again.
This commit is contained in:
John Cupitt 2014-08-03 17:59:25 +01:00
parent 004c98f296
commit ebec31fe4a
4 changed files with 37 additions and 22 deletions

12
TODO
View File

@ -1,10 +1,13 @@
- vipsthumbnail -t plus large -s seems to fail?
- try:
change caching:
$ vipsthumbnail Chicago.png --vips-concurrency=1
memory: high-water mark 180.57 MB
$ vipsthumbnail Chicago.png --vips-concurrency=4
memory: high-water mark 180.57 MB
- autorotate should make a mem copy if it find rotation is necessary
shouldn't memuse drop with concurrency 1?
- remove second vips_cache()
- bicubic adds noise to 255/255/255, why? try babe.jpg background
- experiment with size down to two sizes above in vipsthumbnail
@ -18,7 +21,6 @@
- bicubic adds noise to 255/255/255, why? try babe.jpg background

View File

@ -862,7 +862,7 @@ write_vips( Write *write, int compress, int interlace )
/* Write data.
*/
for( i = 0; i < nb_passes; i++ )
if( vips_sink_disc( write->in, write_png_block, write ) )
if( vips_sink_disc( in, write_png_block, write ) )
return( -1 );
/* The setjmp() was held by our background writer: reset it.

View File

@ -2781,6 +2781,24 @@ vips_image_wio_input( VipsImage *image )
*/
g_object_unref( t1 );
/* We need to zap any start/gen/stop callbacks. If we don't,
* calling vips_region_prepare_to() later to read from this
* image will fail, since it will think it need to create the
* image, not read from it.
*/
image->start_fn = NULL;
image->generate_fn = NULL;
image->stop_fn = NULL;
image->client1 = NULL;
image->client2 = NULL;
/* ... and that may confuse any regions which are trying to
* generate from this image.
*/
if( image->regions )
vips_warn( "vips_image_wio_input", "%s",
"rewinding image with active regions" );
break;
case VIPS_IMAGE_OPENIN:

View File

@ -570,12 +570,18 @@ thumbnail_crop( VipsObject *process, VipsImage *im )
static VipsImage *
thumbnail_rotate( VipsObject *process, VipsImage *im )
{
VipsImage **t = (VipsImage **) vips_object_local_array( process, 1 );
VipsImage **t = (VipsImage **) vips_object_local_array( process, 2 );
VipsAngle angle = get_angle( im );
if( rotate_image ) {
if( vips_rot( im, &t[0], get_angle( im ), NULL ) )
if( rotate_image &&
angle != VIPS_ANGLE_0 ) {
/* Need to copy to memory, we have to stay seq.
*/
t[0] = vips_image_new_memory();
if( vips_image_write( im, t[0] ) ||
vips_rot( t[0], &t[1], angle, NULL ) )
return( NULL );
im = t[0];
im = t[1];
(void) vips_image_remove( im, ORIENTATION );
}
@ -589,8 +595,6 @@ thumbnail_rotate( VipsObject *process, VipsImage *im )
static int
thumbnail_write( VipsObject *process, VipsImage *im, const char *filename )
{
VipsImage **t = (VipsImage **) vips_object_local_array( process, 1 );
char *file;
char *p;
char buf[FILENAME_MAX];
@ -622,16 +626,7 @@ thumbnail_write( VipsObject *process, VipsImage *im, const char *filename )
g_free( file );
/* We need to cache the whole of the thumbnail before we write it
* in case we are writing an interlaced image. Interlaced png (for
* example) will make 7 passes over the image during write.
*/
if( vips_tilecache( im, &t[0],
"threaded", TRUE,
"persistent", TRUE,
"max_tiles", -1,
NULL ) ||
vips_image_write_to_file( t[0], output_name, NULL ) ) {
if( vips_image_write_to_file( im, output_name, NULL ) ) {
g_free( output_name );
return( -1 );
}