fix --fail option to jpegload

getting --fail on jpegload working means tilecache must terminate on tile
calc error

make openslideload not report tile calc errors, it might need a --fail
option too

see https://github.com/jcupitt/libvips/issues/474
This commit is contained in:
John Cupitt 2016-07-11 10:07:41 +01:00
parent f294ec5d9b
commit 828b36dfe5
4 changed files with 46 additions and 23 deletions

View File

@ -31,6 +31,8 @@
* - cache minimisation is optional, see "persistent" flag
* 26/8/14 Lovell
* - free the hash table in _dispose()
* 11/7/16
* - terminate on tile calc error
*/
/*
@ -609,6 +611,9 @@ vips_tile_cache_gen( VipsRegion *or,
VipsTile *tile;
GSList *work;
GSList *p;
int result;
result = 0;
VIPS_GATE_START( "vips_tile_cache_gen: wait1" );
@ -658,8 +663,6 @@ vips_tile_cache_gen( VipsRegion *or,
tile = (VipsTile *) p->data;
if( tile->state == VIPS_TILE_STATE_PEND ) {
int result;
tile->state = VIPS_TILE_STATE_CALC;
VIPS_DEBUG_MSG_RED( "vips_tile_cache_gen: "
@ -688,11 +691,11 @@ vips_tile_cache_gen( VipsRegion *or,
}
/* If there was an error calculating this
* tile, just warn and carry on.
* tile, black it out and terminate
* calculation. We have to stop so we can
* support things like --fail on jpegload.
*
* This can happen with things like reading
* .scn files via openslide. We don't want the
* read to fail because of one broken tile.
* Don't return early, we'd deadlock.
*/
if( result ) {
VIPS_DEBUG_MSG_RED(
@ -707,6 +710,8 @@ vips_tile_cache_gen( VipsRegion *or,
vips_error_clear();
vips_region_black( tile->region );
*stop = TRUE;
}
tile->state = VIPS_TILE_STATE_DATA;
@ -749,7 +754,7 @@ vips_tile_cache_gen( VipsRegion *or,
g_mutex_unlock( cache->lock );
return( 0 );
return( result );
}
static int

View File

@ -74,6 +74,8 @@
* memory for progressive jpg files
* 26/5/16
* - switch to new orientation tag
* 11/7/16
* - new --fail handling
*/
/*
@ -186,16 +188,10 @@ readjpeg_free( ReadJpeg *jpeg )
result = 0;
if( jpeg->eman.pub.num_warnings != 0 ) {
if( jpeg->fail ) {
vips_error( "VipsJpeg", "%s", vips_error_buffer() );
result = -1;
}
else {
vips_warn( "VipsJpeg",
_( "read gave %ld warnings" ),
jpeg->eman.pub.num_warnings );
vips_warn( NULL, "%s", vips_error_buffer() );
}
vips_warn( "VipsJpeg",
_( "read gave %ld warnings" ),
jpeg->eman.pub.num_warnings );
vips_warn( NULL, "%s", vips_error_buffer() );
/* Make the message only appear once.
*/
@ -991,6 +987,25 @@ read_jpeg_generate( VipsRegion *or,
if( setjmp( jpeg->eman.jmp ) )
return( -1 );
/* If --fail is set, we make read fail on any warnings. This will stop
* on any errors from the previous jpeg_read_scanlines().
*/
if( jpeg->eman.pub.num_warnings > 0 &&
jpeg->fail ) {
vips_error( "VipsJpeg",
_( "read gave %ld warnings" ),
jpeg->eman.pub.num_warnings );
vips_error( NULL, "%s", vips_error_buffer() );
/* Make the message only appear once.
*/
jpeg->eman.pub.num_warnings = 0;
*stop = TRUE;
return( -1 );
}
for( y = 0; y < r->height; y++ ) {
JSAMPROW row_pointer[1];

View File

@ -47,6 +47,8 @@
* - do argb -> rgba for associated as well
* 27/1/15
* - unpremultiplication speedups for fully opaque/transparent pixels
* 11/7/16
* - just warn on tile read error
*/
/*
@ -471,14 +473,16 @@ vips__openslide_generate( VipsRegion *out,
rslide->level,
r->width, r->height );
/* Only warn on error: we don't want to make the whole image unreadable
* because of one broken tile.
*
* FIXME ... add a --fail option like jpegload
*/
error = openslide_get_error( rslide->osr );
if( error ) {
vips_error( "openslide2vips",
if( error )
vips_warn( "openslide2vips",
_( "reading region: %s" ), error );
return( -1 );
}
/* Since we are inside a cache, we know buf must be continuous.
*/
argb2rgba( buf, n, bg );

View File

@ -227,7 +227,6 @@ 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;