Merge remote-tracking branch 'origin/7.28'

This commit is contained in:
John Cupitt 2012-04-12 10:24:11 +01:00
commit d3f9d0fd7d
8 changed files with 43 additions and 19 deletions

View File

@ -12,6 +12,8 @@
NOP NOP
- cast to unsigned int now removes <0 values - cast to unsigned int now removes <0 values
- vips7 interface to openslide now supports :,level,associated options - vips7 interface to openslide now supports :,level,associated options
- make vips8 cache smaller
- more accurate progress reporting
13/3/12 started 7.28.2 13/3/12 started 7.28.2
- xres/yres tiffsave args were broken - xres/yres tiffsave args were broken

View File

@ -476,7 +476,7 @@ int vips_image_written( VipsImage *image );
void vips_image_invalidate_all( VipsImage *image ); void vips_image_invalidate_all( VipsImage *image );
void vips_image_preeval( VipsImage *image ); void vips_image_preeval( VipsImage *image );
void vips_image_eval( VipsImage *image, int w, int h ); void vips_image_eval( VipsImage *image, guint64 processed );
void vips_image_posteval( VipsImage *image ); void vips_image_posteval( VipsImage *image );
void vips_image_set_progress( VipsImage *image, gboolean progress ); void vips_image_set_progress( VipsImage *image, gboolean progress );

View File

@ -74,18 +74,23 @@ char *vips__cache_max_files = NULL;
gboolean vips__cache_dump = FALSE; gboolean vips__cache_dump = FALSE;
gboolean vips__cache_trace = FALSE; gboolean vips__cache_trace = FALSE;
/* Max number of cached operations. /* Max number of cached operations. We are likely to trim due to memuse or
* file use before we hit this limit.
*/ */
static int vips_cache_max = 10000; static int vips_cache_max = 10000;
/* How many tracked open files we allow before we start dropping cache. /* How many tracked open files we allow before we start dropping cache.
*/ */
static int vips_cache_max_files = 900; static int vips_cache_max_files = 100;
/* How much RAM we spend on caches before we start dropping cached operations /* How much RAM we spend on caches before we start dropping cached operations
* ... default 1gb. * ... default 100mb.
*
* It was 1gb, but that's a lot of memory for things like vipsthumbnail where
* there will be (almost) no reuse. Default low and let apps raise it if it'd
* be useful.
*/ */
static size_t vips_cache_max_mem = 1024 * 1024 * 1024; static size_t vips_cache_max_mem = 100 * 1024 * 1024;
/* Hold a ref to all "recent" operations. /* Hold a ref to all "recent" operations.
*/ */
@ -542,7 +547,8 @@ vips_cache_trim( void )
{ {
VipsOperation *operation; VipsOperation *operation;
while( (g_hash_table_size( vips_cache_table ) > vips_cache_max || while( vips_cache_table &&
(g_hash_table_size( vips_cache_table ) > vips_cache_max ||
vips_tracked_get_files() > vips_cache_max_files || vips_tracked_get_files() > vips_cache_max_files ||
vips_tracked_get_mem() > vips_cache_max_mem) && vips_tracked_get_mem() > vips_cache_max_mem) &&
(operation = vips_cache_select()) ) { (operation = vips_cache_select()) ) {

View File

@ -1092,8 +1092,8 @@ vips_progress_add( VipsImage *image )
return( 0 ); return( 0 );
} }
void static void
vips_progress_update( VipsProgress *progress, int w, int h ) vips_progress_update( VipsProgress *progress, guint64 processed )
{ {
float prop; float prop;
@ -1102,11 +1102,11 @@ vips_progress_update( VipsProgress *progress, int w, int h )
g_assert( progress ); g_assert( progress );
progress->run = g_timer_elapsed( progress->start, NULL ); progress->run = g_timer_elapsed( progress->start, NULL );
progress->npels += w * h; progress->npels = processed;
prop = (float) progress->npels / (float) progress->tpels; prop = (float) progress->npels / (float) progress->tpels;
progress->percent = 100 * prop; progress->percent = 100 * prop;
/* Don't estiomate eta until we are 10% in. /* Don't estimate eta until we are 10% in.
*/ */
if( prop > 0.1 ) if( prop > 0.1 )
progress->eta = (1.0 / prop) * progress->run - progress->run; progress->eta = (1.0 / prop) * progress->run - progress->run;
@ -1135,10 +1135,10 @@ vips_image_preeval( VipsImage *image )
} }
} }
/* Another w * h pixels have been processed. /* Updated the number of pixels that have been processed.
*/ */
void void
vips_image_eval( VipsImage *image, int w, int h ) vips_image_eval( VipsImage *image, guint64 processed )
{ {
if( image->progress_signal ) { if( image->progress_signal ) {
VIPS_DEBUG_MSG( "vips_image_eval: %p\n", image ); VIPS_DEBUG_MSG( "vips_image_eval: %p\n", image );
@ -1146,7 +1146,7 @@ vips_image_eval( VipsImage *image, int w, int h )
g_assert( vips_object_sanity( g_assert( vips_object_sanity(
VIPS_OBJECT( image->progress_signal ) ) ); VIPS_OBJECT( image->progress_signal ) ) );
vips_progress_update( image->time, w, h ); vips_progress_update( image->time, processed );
/* For vips7 compat, update the ->time on the signalling image /* For vips7 compat, update the ->time on the signalling image
* too, even though it may have a different width/height to * too, even though it may have a different width/height to
@ -1154,7 +1154,7 @@ vips_image_eval( VipsImage *image, int w, int h )
*/ */
if( image->progress_signal->time != image->time ) if( image->progress_signal->time != image->time )
vips_progress_update( image->progress_signal->time, vips_progress_update( image->progress_signal->time,
w, h ); processed );
g_signal_emit( image->progress_signal, g_signal_emit( image->progress_signal,
vips_image_signals[SIG_EVAL], 0, image->time ); vips_image_signals[SIG_EVAL], 0, image->time );
@ -1878,7 +1878,7 @@ vips_image_write_line( VipsImage *image, int ypos, VipsPel *linebuffer )
/* Trigger evaluation callbacks for this image. /* Trigger evaluation callbacks for this image.
*/ */
vips_image_eval( image, image->Xsize, 1 ); vips_image_eval( image, ypos * image->Xsize );
if( vips_image_get_kill( image ) ) if( vips_image_get_kill( image ) )
return( -1 ); return( -1 );

View File

@ -211,6 +211,8 @@ vips_sink_base_init( SinkBase *sink_base, VipsImage *image )
vips_get_tile_size( image, vips_get_tile_size( image,
&sink_base->tile_width, &sink_base->tile_height, &sink_base->tile_width, &sink_base->tile_height,
&sink_base->nlines ); &sink_base->nlines );
sink_base->processed = 0;
} }
static int static int
@ -283,6 +285,10 @@ vips_sink_base_allocate( VipsThreadState *state, void *a, gboolean *stop )
*/ */
sink_base->x += sink_base->tile_width; sink_base->x += sink_base->tile_width;
/* Add the number of pixels we've just allocated to progress.
*/
sink_base->processed += state->pos.width * state->pos.height;
return( 0 ); return( 0 );
} }
@ -305,14 +311,12 @@ vips_sink_base_progress( void *a )
{ {
SinkBase *sink_base = (SinkBase *) a; SinkBase *sink_base = (SinkBase *) a;
VIPS_DEBUG_MSG( "vips_sink_base_progress: %d x %d\n", VIPS_DEBUG_MSG( "vips_sink_base_progress:\n" );
sink_base->tile_width, sink_base->tile_height );
/* Trigger any eval callbacks on our source image and /* Trigger any eval callbacks on our source image and
* check for errors. * check for errors.
*/ */
vips_image_eval( sink_base->im, vips_image_eval( sink_base->im, sink_base->processed );
sink_base->tile_width, sink_base->tile_height );
if( vips_image_get_kill( sink_base->im ) ) if( vips_image_get_kill( sink_base->im ) )
return( -1 ); return( -1 );

View File

@ -56,6 +56,10 @@ typedef struct _SinkBase {
int tile_height; int tile_height;
int nlines; int nlines;
/* The number of pixels allocate has allocated. Used for progress
* feedback.
*/
guint64 processed;
} SinkBase; } SinkBase;
/* Some function we can share. /* Some function we can share.

View File

@ -396,6 +396,10 @@ wbuffer_allocate_fn( VipsThreadState *state, void *a, gboolean *stop )
*/ */
sink_base->x += sink_base->tile_width; sink_base->x += sink_base->tile_width;
/* Add the number of pixels we've just allocated to progress.
*/
sink_base->processed += state->pos.width * state->pos.height;
return( 0 ); return( 0 );
} }

View File

@ -240,6 +240,10 @@ sink_memory_area_allocate_fn( VipsThreadState *state, void *a, gboolean *stop )
*/ */
sink_base->x += sink_base->tile_width; sink_base->x += sink_base->tile_width;
/* Add the number of pixels we've just allocated to progress.
*/
sink_base->processed += state->pos.width * state->pos.height;
return( 0 ); return( 0 );
} }