better cache trace, small fixes

This commit is contained in:
John Cupitt 2012-10-29 17:19:15 +00:00
parent 15ba5c2cab
commit 6e1e3d4be1
5 changed files with 48 additions and 21 deletions

7
TODO
View File

@ -1,3 +1,10 @@
- see vips_col_sRGB2XYZ()
t_r2Yr[] is a 1501 element array, but we just index with a uchar
trim this down!
- add mono as a colourspace? also rad?
- something to test if an image is in a supported colourspace?

View File

@ -228,12 +228,20 @@ calcul_tables( void *client )
static struct im_col_tab_disp *
vips_col_make_tables_RGB( void )
{
static GOnce once = G_ONCE_INIT;
static struct im_col_tab_disp table;
static struct im_col_tab_disp *table = NULL;
(void) g_once( &once, calcul_tables, &table );
/* We want to avoid having a mutex in this path, so use gonce and a
* static var instead.
*/
if( !table ) {
static GOnce once = G_ONCE_INIT;
static struct im_col_tab_disp table_memory;
return( &table );
(void) g_once( &once, calcul_tables, &table_memory );
table = &table_memory;
}
return( table );
}
/* Computes the transform: r,g,b => Yr,Yg,Yb. It finds Y values in
@ -248,9 +256,9 @@ vips_col_sRGB2XYZ( int r, int g, int b, float *X, float *Y, float *Z )
float Yr, Yg, Yb;
int i;
r = VIPS_CLIP( 0, r, 255 );
g = VIPS_CLIP( 0, g, 255 );
b = VIPS_CLIP( 0, b, 255 );
r = VIPS_CLIP( 0, r, 255 );
g = VIPS_CLIP( 0, g, 255 );
b = VIPS_CLIP( 0, b, 255 );
i = r / table->ristep;
Yr = table->t_r2Yr[i];

View File

@ -127,6 +127,11 @@ vips_colour_build( VipsObject *object )
if( vips_image_pio_input( colour->in[i] ) )
return( -1 );
/* colour->in[] must be NULL-terminated, we use it as an arg to
* vips_start_many().
*/
g_assert( !colour->in[colour->n] );
if( vips_image_copy_fields_array( colour->out, colour->in ) )
return( -1 );
vips_demand_hint_array( colour->out,
@ -221,8 +226,9 @@ vips_colour_space_build( VipsObject *object )
return( -1 );
colour->n = 1;
colour->in = (VipsImage **) vips_object_local_array( object, 1 );
colour->in = (VipsImage **) vips_object_local_array( object, 2 );
colour->in[0] = in;
colour->in[1] = NULL;
if( colour->in[0] )
g_object_ref( colour->in[0] );
@ -346,8 +352,9 @@ vips_colour_code_build( VipsObject *object )
}
colour->n = 1;
colour->in = (VipsImage **) vips_object_local_array( object, 1 );
colour->in = (VipsImage **) vips_object_local_array( object, 2 );
colour->in[0] = in;
colour->in[1] = NULL;
if( colour->in[0] )
g_object_ref( colour->in[0] );
@ -508,9 +515,10 @@ vips_colour_difference_build( VipsObject *object )
right = t[9];
colour->n = 2;
colour->in = (VipsImage **) vips_object_local_array( object, 2 );
colour->in = (VipsImage **) vips_object_local_array( object, 3 );
colour->in[0] = left;
colour->in[1] = right;
colour->in[2] = NULL;
if( colour->in[0] )
g_object_ref( colour->in[0] );
if( colour->in[1] )

View File

@ -691,8 +691,9 @@ vips_cache_operation_buildp( VipsOperation **operation )
if( (hit = g_hash_table_lookup( vips_cache_table, *operation )) ) {
if( vips__cache_trace ) {
printf( "vips cache: hit %p\n ", hit );
vips_object_print_summary( VIPS_OBJECT( *operation ) );
printf( "vips cache: hit\n" );
printf( "\t" );
vips_object_print_summary( VIPS_OBJECT( hit ) );
}
/* Ref before unref in case *operation == hit.
@ -706,19 +707,21 @@ vips_cache_operation_buildp( VipsOperation **operation )
g_mutex_unlock( vips_cache_lock );
if( !hit ) {
if( vips_object_build( VIPS_OBJECT( *operation ) ) )
return( -1 );
/* Has to be after _build() so we can see output args.
*/
if( vips__cache_trace ) {
if( vips_operation_get_flags( *operation ) &
VIPS_OPERATION_NOCACHE )
printf( "vips cache: uncacheable %p\n ",
*operation );
printf( "vips cache: uncacheable\n" );
else
printf( "vips cache: miss %p\n ", *operation );
printf( "vips cache: miss\n" );
printf( "\t" );
vips_object_print_summary( VIPS_OBJECT( *operation ) );
}
if( vips_object_build( VIPS_OBJECT( *operation ) ) )
return( -1 );
g_mutex_lock( vips_cache_lock );
if( !(vips_operation_get_flags( *operation ) &

View File

@ -221,7 +221,6 @@ vips_operation_vips_operation_print_summary_arg( VipsObject *object,
*/
if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) &&
(argument_class->flags & VIPS_ARGUMENT_INPUT) &&
argument_instance->assigned ) {
const char *name = g_param_spec_get_name( pspec );
GType type = G_PARAM_SPEC_VALUE_TYPE( pspec );
@ -232,7 +231,7 @@ vips_operation_vips_operation_print_summary_arg( VipsObject *object,
g_value_init( &gvalue, type );
g_object_get_property( G_OBJECT( object ), name, &gvalue );
str = g_strdup_value_contents( &gvalue );
vips_buf_appendf( buf, " %s", str );
vips_buf_appendf( buf, " %s=%s", name, str );
g_free( str );
g_value_unset( &gvalue );
}
@ -246,10 +245,12 @@ vips_operation_summary( VipsObject *object, VipsBuf *buf )
VipsOperation *operation = VIPS_OPERATION( object );
VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object );
vips_buf_appendf( buf, "- %s", object_class->nickname );
vips_buf_appendf( buf, "%s", object_class->nickname );
vips_argument_map( VIPS_OBJECT( operation ),
vips_operation_vips_operation_print_summary_arg, buf, NULL );
vips_buf_appends( buf, " -" );
VIPS_OBJECT_CLASS( vips_operation_parent_class )->
summary( object, buf );
}