export a better cache operator for nip2

This commit is contained in:
John Cupitt 2014-05-10 14:00:01 +01:00
parent 4d17ebb3b4
commit 22d525d54f
5 changed files with 38 additions and 29 deletions

View File

@ -30,6 +30,7 @@
- added @container option to dzsave - added @container option to dzsave
- support 1/2/4 bit palette tiff images with alpha - support 1/2/4 bit palette tiff images with alpha
- vips_system() now uses g_spawn_command_line_sync() - vips_system() now uses g_spawn_command_line_sync()
- added im_tile_cache_random() to help nip2
6/3/14 started 7.38.6 6/3/14 started 7.38.6
- grey ramp minimum was wrong - grey ramp minimum was wrong

21
TODO
View File

@ -3,27 +3,6 @@
- why is cache in nip2 so slow? its awful
investigate again
is it using vips_sinkscreen()? should it use tilecache?
Cache calls cache in _stdenv.def
cache calls im_cache()
im_cache() calls vips_sink_screen()
im_tile_cache() calls vips_tilecache()
add im_tile_cache to vips7 op db, try using it from nip2
- test draw_mask on labq images - test draw_mask on labq images
we probably need to unpack the ink back to double before blending we probably need to unpack the ink back to double before blending

View File

@ -497,26 +497,24 @@ static im_function cache_desc = {
cache_args /* Arg list */ cache_args /* Arg list */
}; };
/* Call im_tile_cache() via arg vector.
*/
static int static int
tile_cache_vec( im_object *argv ) tile_cache_random_vec( im_object *argv )
{ {
int tile_width = *((int *) argv[2]); int tile_width = *((int *) argv[2]);
int tile_height = *((int *) argv[3]); int tile_height = *((int *) argv[3]);
int max_tiles = *((int *) argv[4]); int max_tiles = *((int *) argv[4]);
return( im_tile_cache( argv[0], argv[1], return( im_tile_cache_random( argv[0], argv[1],
tile_width, tile_height, max_tiles ) ); tile_width, tile_height, max_tiles ) );
} }
/* Description of im_cache. /* Description of im_cache.
*/ */
static im_function tile_cache_desc = { static im_function tile_cache_random_desc = {
"im_tile_cache", /* Name */ "im_tile_cache_random", /* Name */
"cache results of an operation",/* Description */ "cache results of an operation",/* Description */
0, /* Flags */ 0, /* Flags */
tile_cache_vec, /* Dispatch function */ tile_cache_random_vec, /* Dispatch function */
VIPS_NUMBER( cache_args ), /* Size of arg list */ VIPS_NUMBER( cache_args ), /* Size of arg list */
cache_args /* Arg list */ cache_args /* Arg list */
}; };
@ -570,7 +568,7 @@ static im_function binfile_desc = {
static im_function *iofuncs_list[] = { static im_function *iofuncs_list[] = {
&binfile_desc, &binfile_desc,
&cache_desc, &cache_desc,
&tile_cache_desc, &tile_cache_random_desc,
&concurrency_get_desc, &concurrency_get_desc,
&getext_desc, &getext_desc,
&guess_prefix_desc, &guess_prefix_desc,

View File

@ -4450,6 +4450,34 @@ im_tile_cache( IMAGE *in, IMAGE *out,
return( 0 ); return( 0 );
} }
/* This is the one used by nip2's menu for caching images. Random access and
* persistent.
*/
int
im_tile_cache_random( IMAGE *in, IMAGE *out,
int tile_width, int tile_height, int max_tiles )
{
VipsImage *x;
if( vips_tilecache( in, &x,
"tile_width", tile_width,
"tile_height", tile_height,
"max_tiles", max_tiles,
"access", VIPS_ACCESS_RANDOM,
"persistent", TRUE,
"threaded", TRUE,
NULL ) )
return( -1 );
if( im_copy( x, out ) ) {
g_object_unref( x );
return( -1 );
}
g_object_unref( x );
return( 0 );
}
static int static int
im__affinei( VipsImage *in, VipsImage *out, im__affinei( VipsImage *in, VipsImage *out,
VipsInterpolate *interpolate, VipsTransformation *trn ) VipsInterpolate *interpolate, VipsTransformation *trn )

View File

@ -777,6 +777,9 @@ int im_argb2rgba( VipsImage *in, VipsImage *out );
int im_falsecolour( VipsImage *in, VipsImage *out ); int im_falsecolour( VipsImage *in, VipsImage *out );
int im_gammacorrect( VipsImage *in, VipsImage *out, double exponent ); int im_gammacorrect( VipsImage *in, VipsImage *out, double exponent );
int im_tile_cache_random( IMAGE *in, IMAGE *out,
int tile_width, int tile_height, int max_tiles );
int im_shrink( VipsImage *in, VipsImage *out, double xshrink, double yshrink ); int im_shrink( VipsImage *in, VipsImage *out, double xshrink, double yshrink );
int im_affinei( VipsImage *in, VipsImage *out, int im_affinei( VipsImage *in, VipsImage *out,
VipsInterpolate *interpolate, VipsInterpolate *interpolate,