From 8653b23810bf2d676f9de7ee73c2912140ed84d1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 23 Aug 2012 21:44:14 +0100 Subject: [PATCH] better handling of jpeg warnings --- libvips/conversion/tilecache.c | 13 +++++++++---- libvips/foreign/jpeg2vips.c | 2 +- libvips/foreign/vips2jpeg.c | 1 + libvips/iofuncs/error.c | 6 ++++-- tools/vips.c | 23 ++++++++++++++++++----- 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/libvips/conversion/tilecache.c b/libvips/conversion/tilecache.c index a8fe9a63..3040a652 100644 --- a/libvips/conversion/tilecache.c +++ b/libvips/conversion/tilecache.c @@ -398,6 +398,8 @@ vips_tile_destroy( VipsTile *tile ) static void vips_block_cache_init( VipsBlockCache *cache ) { + printf( "vips_block_cache_init\n" ); + cache->tile_width = 128; cache->tile_height = 128; cache->max_tiles = 1000; @@ -652,10 +654,6 @@ vips_line_cache_build( VipsObject *object ) block_cache->tile_width = block_cache->in->Xsize; block_cache->tile_height = 1; - /* This adjust with request size, see vips_line_cache_gen(). - */ - block_cache->max_tiles = 100; - if( vips_image_pio_input( block_cache->in ) ) return( -1 ); @@ -692,6 +690,13 @@ vips_line_cache_class_init( VipsLineCacheClass *class ) static void vips_line_cache_init( VipsLineCache *cache ) { + printf( "vips_line_cache_init\n" ); + + /* This adjust with request size, see vips_line_cache_gen(). + */ + ((VipsBlockCache *) cache)->max_tiles = 500; + + ((VipsBlockCache *) cache)->strategy = VIPS_CACHE_SEQUENTIAL; } /** diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index 750496fe..31a0ffc2 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -167,7 +167,7 @@ readjpeg_free( ReadJpeg *jpeg ) vips_warn( "VipsJpeg", _( "read gave %ld warnings" ), jpeg->eman.pub.num_warnings ); - vips_warn( "VipsJpeg", "%s", vips_error_buffer() ); + vips_warn( NULL, "%s", vips_error_buffer() ); } /* Make the message only appear once. diff --git a/libvips/foreign/vips2jpeg.c b/libvips/foreign/vips2jpeg.c index 7aea3f86..ee4e0e64 100644 --- a/libvips/foreign/vips2jpeg.c +++ b/libvips/foreign/vips2jpeg.c @@ -202,6 +202,7 @@ write_new( VipsImage *in ) write->cinfo.err = jpeg_std_error( &write->eman.pub ); write->eman.pub.error_exit = vips__new_error_exit; write->eman.pub.output_message = vips__new_output_message; + write->eman.pub.output_message = vips__new_output_message; write->eman.fp = NULL; write->profile_bytes = NULL; write->profile_length = 0; diff --git a/libvips/iofuncs/error.c b/libvips/iofuncs/error.c index 097708f4..add4d5ec 100644 --- a/libvips/iofuncs/error.c +++ b/libvips/iofuncs/error.c @@ -311,7 +311,8 @@ vips_vdiag( const char *domain, const char *fmt, va_list ap ) if( !g_getenv( IM_DIAGNOSTICS ) ) { g_mutex_lock( vips__global_lock ); (void) fprintf( stderr, _( "%s: " ), _( "vips diagnostic" ) ); - (void) fprintf( stderr, _( "%s: " ), domain ); + if( domain ) + (void) fprintf( stderr, _( "%s: " ), domain ); (void) vfprintf( stderr, fmt, ap ); (void) fprintf( stderr, "\n" ); g_mutex_unlock( vips__global_lock ); @@ -361,7 +362,8 @@ vips_vwarn( const char *domain, const char *fmt, va_list ap ) if( !g_getenv( IM_WARNING ) ) { g_mutex_lock( vips__global_lock ); (void) fprintf( stderr, _( "%s: " ), _( "vips warning" ) ); - (void) fprintf( stderr, _( "%s: " ), domain ); + if( domain ) + (void) fprintf( stderr, _( "%s: " ), domain ); (void) vfprintf( stderr, fmt, ap ); (void) fprintf( stderr, "\n" ); g_mutex_unlock( vips__global_lock ); diff --git a/tools/vips.c b/tools/vips.c index afff7169..0a25b847 100644 --- a/tools/vips.c +++ b/tools/vips.c @@ -1073,7 +1073,8 @@ main( int argc, char **argv ) * since we don't want to use the vips7 compat wrappers in vips8 * unless we have to. They don't support all args types. */ - if( action && !handled && + if( action && + !handled && (fn = im_find_function( action )) ) { (void) add_main_group( context, NULL ); parse_options( context, &argc, argv ); @@ -1087,11 +1088,17 @@ main( int argc, char **argv ) handled = TRUE; } - im_error_clear(); + + /* im_find_function() set an error msg. + */ + if( action && + !handled ) + im_error_clear(); /* Could be a vips8 VipsOperation. */ - if( action && !handled && + if( action && + !handled && (operation = vips_operation_new( action )) ) { main_group = add_main_group( context, operation ); vips_call_options( main_group, operation ); @@ -1113,9 +1120,15 @@ main( int argc, char **argv ) handled = TRUE; } - im_error_clear(); - if( action && !handled ) { + /* vips_operation_new() set an error msg for unknown operation. + */ + if( action && + !handled ) + im_error_clear(); + + if( action && + !handled ) { printf( "%s", _( "possible actions:\n" ) ); for( i = 0; i < VIPS_NUMBER( actions ); i++ ) printf( "%10s - %s\n",