add sequential mode to vips7

the tiff and jpg readers let you give :seq as well
This commit is contained in:
John Cupitt 2012-06-24 09:44:50 +01:00
parent daac11b01c
commit 3694a2edc5
10 changed files with 37 additions and 12 deletions

View File

@ -8,6 +8,7 @@
- vipsthumbnail no longer removes profiles by default
- much more gentle sharpening in thumbnails
- added "minimise" signal, used by tilecache to drop
- add :seq support to im_tiff2vips(), im_jpeg2vips() ... helps ruby-vips
18/6/12 started 7.28.9
- slightly more memory debugging output

9
TODO
View File

@ -1,9 +1,10 @@
- tile cache doesn't need to copy if request fits within a tile
- vips_image_minimise_all( im );
though doing a copy means that we can safely drop the cache without leaving
dangling pointers
call this at the end of thereadpool_run(), doesnt seem to trigger the
minimise callback on tilecache?
it does trigger it if we turn OFF seq mode??! how odd
- could jpeg load via memory buffer support minimise too?
blocking bugs

View File

@ -15,6 +15,8 @@
* - use im_prepare_to() and avoid making a sequence for every cache tile
* 5/12/11
* - rework as a class
* 23/6/12
* - listen for "minimise" signal
*/
/*
@ -346,6 +348,14 @@ vips_tile_cache_gen( VipsRegion *or,
g_mutex_lock( cache->lock );
/* If the output region fits within a tile (tiles can become quite
* large for seq caches, for example), we could save a copy by routing
* the output region directly to the tile.
*
* However this would mean that tile drop on minimise could then leave
* dangling pointers, if minimuse was called on an active pipeline.
*/
VIPS_DEBUG_MSG( "vips_tile_cache_gen: "
"left = %d, top = %d, width = %d, height = %d\n",
r->left, r->top, r->width, r->height );
@ -383,8 +393,6 @@ vips_tile_cache_gen( VipsRegion *or,
static void
vips_tile_cache_minimise( VipsImage *image, VipsTileCache *cache )
{
printf( "vips_tile_cache_minimise:\n" );
vips_tile_cache_drop_all( cache );
}

View File

@ -52,6 +52,7 @@ im_jpeg2vips( const char *name, IMAGE *out )
char *p, *q;
int shrink;
gboolean fail_on_warn;
gboolean sequential;
VipsImage *t;
/* By default, we ignore any warnings. We want to get as much of
@ -64,6 +65,7 @@ im_jpeg2vips( const char *name, IMAGE *out )
im_filename_split( name, filename, mode );
p = &mode[0];
shrink = 1;
sequential = FALSE;
if( (q = im_getnextoption( &p )) ) {
shrink = atoi( q );
@ -78,10 +80,15 @@ im_jpeg2vips( const char *name, IMAGE *out )
if( im_isprefix( "fail", q ) )
fail_on_warn = TRUE;
}
if( (q = im_getnextoption( &p )) ) {
if( im_isprefix( "seq", q ) )
sequential = TRUE;
}
if( vips_jpegload( filename, &t,
"shrink", shrink,
"fail", fail_on_warn,
"sequential", sequential,
NULL ) )
return( -1 );

View File

@ -55,6 +55,7 @@ im_tiff2vips( const char *name, IMAGE *out )
char mode[FILENAME_MAX];
char *p, *q;
int page;
gboolean sequential;
VipsImage *t;
im_filename_split( name, filename, mode );
@ -64,9 +65,14 @@ im_tiff2vips( const char *name, IMAGE *out )
if( (q = im_getnextoption( &p )) ) {
page = atoi( q );
}
if( (q = im_getnextoption( &p )) ) {
if( im_isprefix( "seq", q ) )
sequential = TRUE;
}
if( vips_tiffload( filename, &t,
"page", page,
"sequential", sequential,
NULL ) )
return( -1 );
if( vips_image_write( t, out ) ) {

View File

@ -782,6 +782,12 @@ vips_foreign_load_start( VipsImage *out, void *a, void *b )
*/
if( !vips_foreign_load_iscompat( load->real, out ) )
return( NULL );
/* We have to tell vips that out depends on real. We've set
* the demand hint below, but not given an input there.
*/
vips_demand_hint( load->out, load->out->dhint,
load->real, NULL );
}
return( vips_region_new( load->real ) );

View File

@ -905,7 +905,7 @@ read_jpeg_image( ReadJpeg *jpeg, VipsImage *out )
jpeg->decompressing = TRUE;
#ifdef DEBUG
printf( "read_jpeg_image: starting deompress\n" );
printf( "read_jpeg_image: starting decompress\n" );
#endif /*DEBUG*/
if( vips_image_generate( t[0],

View File

@ -329,7 +329,7 @@ vips_demand_hint_array( VipsImage *image, VipsDemandStyle hint, VipsImage **in )
for( i = 0; i < len; i++ )
vips__link_make( in[i], image );
/* Set a flag on the image to say we remember to call this thing.
/* Set a flag on the image to say we remembered to call this thing.
* vips_image_generate() and friends check this.
*/
image->hint_set = TRUE;

View File

@ -1111,8 +1111,6 @@ vips_image_minimise_all_cb( VipsImage *image )
void
vips_image_minimise_all( VipsImage *image )
{
printf( "vips_image_minimise_all:\n" );
(void) vips__link_map( image, TRUE,
(VipsSListMap2Fn) vips_image_minimise_all_cb, NULL, NULL );
}

View File

@ -913,8 +913,6 @@ vips_threadpool_run( VipsImage *im,
vips_threadpool_free( pool );
/* Ask the pipeline to drop into low-mem-use mode now we're done.
*/
vips_image_minimise_all( im );
return( result );