remove wio_output

This commit is contained in:
John Cupitt 2011-12-21 12:08:29 +00:00
parent b4ae37819e
commit a62f5f8832
25 changed files with 44 additions and 89 deletions

21
TODO
View File

@ -1,15 +1,20 @@
- what should we call before writing to the ->data pointer?
vips_image_wio_output() just checks the desc, it does no allocation
vips__image_write_prepare() is an internal function
we need a new API thing to replace both these just for the pre-data case,
and we need to make a note of it in VIPS_IMAGE_ADDR()
- test rad read/write with real images (add to nip2 checks?)
- test matio load with real images (add to nip2 checks?)
- remove uses of vips_image_pio_output(), this is done for you by generate
now
do we need vips_image_wio_output()? can't vips_image_write_line() call this
as well?
we need it in case we write to the data pointer of a "t" image I guess
- magickload is broken
$ vips magickload healthygirl.jpg x.v

View File

@ -329,8 +329,6 @@ vips_arithmetic_build( VipsObject *object )
vips_check_uncoded( "VipsArithmetic",
arithmetic->in[i] ) )
return( -1 );
if( vips_image_pio_output( arithmetic->out ) )
return( -1 );
format = (VipsImage **)
vips_object_local_array( object, arithmetic->n );

View File

@ -131,8 +131,6 @@ vips_bandary_build( VipsObject *object )
vips_error( "VipsBandary", "%s", _( "too many input images" ) );
return( -1 );
}
if( vips_image_pio_output( conversion->out ) )
return( -1 );
for( i = 0; i < bandary->n; i++ )
if( vips_image_pio_input( bandary->in[i] ) ||
vips_check_uncoded( "VipsBandary", bandary->in[i] ) )

View File

@ -93,9 +93,6 @@ vips_black_build( VipsObject *object )
if( VIPS_OBJECT_CLASS( vips_black_parent_class )->build( object ) )
return( -1 );
if( vips_image_pio_output( conversion->out ) )
return( -1 );
vips_image_init_fields( conversion->out,
black->width, black->height, black->bands,
VIPS_FORMAT_UCHAR, VIPS_CODING_NONE,

View File

@ -432,8 +432,7 @@ vips_cast_build( VipsObject *object )
return( vips_image_write( cast->in, conversion->out ) );
if( vips_check_uncoded( "VipsCast", cast->in ) ||
vips_image_pio_input( cast->in ) ||
vips_image_pio_output( conversion->out ) )
vips_image_pio_input( cast->in ) )
return( -1 );
if( vips_image_copy_fields( conversion->out, cast->in ) )

View File

@ -246,8 +246,7 @@ vips_copy_build( VipsObject *object )
if( VIPS_OBJECT_CLASS( vips_copy_parent_class )->build( object ) )
return( -1 );
if( vips_image_pio_input( copy->in ) ||
vips_image_pio_output( conversion->out ) )
if( vips_image_pio_input( copy->in ) )
return( -1 );
if( vips_image_copy_fields( conversion->out, copy->in ) )

View File

@ -326,8 +326,7 @@ vips_embed_build( VipsObject *object )
embed->height == embed->in->Ysize )
return( vips_image_write( embed->in, conversion->out ) );
if( vips_image_pio_input( embed->in ) ||
vips_image_pio_output( conversion->out ) )
if( vips_image_pio_input( embed->in ) )
return( -1 );
switch( embed->extend ) {

View File

@ -149,7 +149,6 @@ vips_extract_area_build( VipsObject *object )
}
if( vips_image_pio_input( extract->in ) ||
vips_image_pio_output( conversion->out ) ||
vips_check_coding_known( "VipsExtractArea", extract->in ) )
return( -1 );

View File

@ -194,8 +194,7 @@ vips_flip_build( VipsObject *object )
if( VIPS_OBJECT_CLASS( vips_flip_parent_class )->build( object ) )
return( -1 );
if( vips_image_pio_input( flip->in ) ||
vips_image_pio_output( conversion->out ) )
if( vips_image_pio_input( flip->in ) )
return( -1 );
if( vips_image_copy_fields( conversion->out, flip->in ) )

View File

@ -261,7 +261,6 @@ vips_insert_build( VipsObject *object )
if( vips_image_pio_input( insert->main ) ||
vips_image_pio_input( insert->sub ) ||
vips_image_pio_output( conversion->out ) ||
vips_check_bands_1orn( "VipsInsert",
insert->main, insert->sub ) ||
vips_check_coding_known( "VipsInsert", insert->main ) ||

View File

@ -158,8 +158,7 @@ vips_replicate_build( VipsObject *object )
if( VIPS_OBJECT_CLASS( vips_replicate_parent_class )->build( object ) )
return( -1 );
if( vips_image_pio_input( replicate->in ) ||
vips_image_pio_output( conversion->out ) )
if( vips_image_pio_input( replicate->in ) )
return( -1 );
if( vips_image_copy_fields( conversion->out, replicate->in ) )

View File

@ -290,8 +290,7 @@ vips_rot_build( VipsObject *object )
if( rot->angle == VIPS_ANGLE_0 )
return( vips_image_write( rot->in, conversion->out ) );
if( vips_image_pio_input( rot->in ) ||
vips_image_pio_output( conversion->out ) )
if( vips_image_pio_input( rot->in ) )
return( -1 );
if( vips_image_copy_fields( conversion->out, rot->in ) )

View File

@ -361,8 +361,7 @@ vips_tile_cache_build( VipsObject *object )
if( VIPS_OBJECT_CLASS( vips_tile_cache_parent_class )->build( object ) )
return( -1 );
if( vips_image_pio_input( cache->in ) ||
vips_image_pio_output( conversion->out ) )
if( vips_image_pio_input( cache->in ) )
return( -1 );
if( vips_image_copy_fields( conversion->out, cache->in ) )

View File

@ -487,8 +487,6 @@ im_wrapmany( IMAGE **in, IMAGE *out, im_wrapmany_fn fn, void *a, void *b )
if( vips_image_pio_input( in[i] ) )
return( -1 );
}
if( vips_image_pio_output( out ) )
return( -1 );
vips_demand_hint_array( out, VIPS_DEMAND_STYLE_THINSTRIP, in );
/* Generate!

View File

@ -281,9 +281,8 @@ read_csv( FILE *fp, VipsImage *out,
if( !read_image )
return( 0 );
if( vips_image_wio_output( out ) ||
!(buf = VIPS_ARRAY( out,
VIPS_IMAGE_N_ELEMENTS( out ), double )) )
if( !(buf = VIPS_ARRAY( out,
VIPS_IMAGE_N_ELEMENTS( out ), double )) )
return( -1 );
for( y = 0; y < lines; y++ ) {

View File

@ -1266,7 +1266,7 @@ vips_foreign_operation_init( void )
extern GType vips_foreign_save_vips_get_type( void );
extern GType vips_foreign_load_raw_get_type( void );
extern GType vips_foreign_save_raw_get_type( void );
extern GType vips_foreign_save_rawfd_get_type( void );
extern GType vips_foreign_save_raw_fd_get_type( void );
extern GType vips_foreign_load_magick_get_type( void );
vips_foreign_load_rad_get_type();
@ -1278,7 +1278,7 @@ vips_foreign_operation_init( void )
vips_foreign_load_analyze_get_type();
vips_foreign_load_raw_get_type();
vips_foreign_save_raw_get_type();
vips_foreign_save_rawfd_get_type();
vips_foreign_save_raw_fd_get_type();
vips_foreign_load_vips_get_type();
vips_foreign_save_vips_get_type();

View File

@ -680,11 +680,6 @@ read_jpeg_image( struct jpeg_decompress_struct *cinfo, IMAGE *out,
int x, y, sz;
JSAMPROW row_pointer[1];
/* Check VIPS.
*/
if( vips_image_wio_output( out ) )
return( -1 );
/* Get size of output line and make a buffer.
*/
sz = cinfo->output_width * cinfo->output_components;
@ -703,10 +698,10 @@ read_jpeg_image( struct jpeg_decompress_struct *cinfo, IMAGE *out,
*/
jpeg_read_scanlines( cinfo, &row_pointer[0], 1 );
if( invert_pels ) {
if( invert_pels )
for( x = 0; x < sz; x++ )
row_pointer[0][x] = 255 - row_pointer[0][x];
}
if( vips_image_write_line( out, y, row_pointer[0] ) )
return( -1 );
}

View File

@ -379,8 +379,6 @@ vips__openexr_read( const char *filename, VipsImage *out )
return( -1 );
read_header( read, out );
if( vips_image_wio_output( out ) )
return( -1 );
for( y = 0; y < height; y++ ) {
if( !ImfInputSetFrameBuffer( read->lines,

View File

@ -333,10 +333,8 @@ vips__openslide_read_associated( const char *filename, VipsImage *out,
raw = vips_image_new_buffer();
vips_object_local( out, raw );
if( !(rslide = readslide_new( filename, raw, 0, associated )) )
return( -1 );
if( vips_image_wio_output( raw ) )
if( !(rslide = readslide_new( filename, raw, 0, associated )) ||
vips_image_wio_output( raw ) )
return( -1 );
openslide_read_associated_image( rslide->osr, rslide->associated,
(uint32_t *) VIPS_IMAGE_ADDR( raw, 0, 0 ) );

View File

@ -307,8 +307,7 @@ read_ascii( FILE *fp, VipsImage *out )
int x, y;
PEL *buf;
if( vips_image_wio_output( out ) ||
!(buf = VIPS_ARRAY( out, VIPS_IMAGE_SIZEOF_LINE( out ), PEL )) )
if( !(buf = VIPS_ARRAY( out, VIPS_IMAGE_SIZEOF_LINE( out ), PEL )) )
return( -1 );
for( y = 0; y < out->Ysize; y++ ) {
@ -352,8 +351,7 @@ read_1bit_ascii( FILE *fp, VipsImage *out )
int x, y;
PEL *buf;
if( vips_image_wio_output( out ) ||
!(buf = VIPS_ARRAY( out, VIPS_IMAGE_SIZEOF_LINE( out ), PEL )) )
if( !(buf = VIPS_ARRAY( out, VIPS_IMAGE_SIZEOF_LINE( out ), PEL )) )
return( -1 );
for( y = 0; y < out->Ysize; y++ ) {
@ -385,8 +383,7 @@ read_1bit_binary( FILE *fp, VipsImage *out )
int bits;
PEL *buf;
if( vips_image_wio_output( out ) ||
!(buf = VIPS_ARRAY( out, VIPS_IMAGE_SIZEOF_LINE( out ), PEL )) )
if( !(buf = VIPS_ARRAY( out, VIPS_IMAGE_SIZEOF_LINE( out ), PEL )) )
return( -1 );
bits = fgetc( fp );

View File

@ -1268,11 +1268,6 @@ read_tilewise( ReadTiff *rtiff, VipsImage *out )
raw = vips_image_new();
vips_object_local( out, raw );
/* Make sure we can write PIO-style.
*/
if( vips_image_pio_output( raw ) )
return( -1 );
/* Parse the TIFF header and set up raw.
*/
if( parse_header( rtiff, raw ) )
@ -1343,11 +1338,6 @@ read_stripwise( ReadTiff *rtiff, VipsImage *out )
printf( "read_stripwise: number_of_strips = %d\n", number_of_strips );
#endif /*DEBUG*/
/* Make sure we can write WIO-style.
*/
if( vips_image_wio_output( out ) )
return( -1 );
/* Make buffers.
*/
if( !(vbuf = VIPS_ARRAY( out, VIPS_IMAGE_SIZEOF_LINE( out ), PEL )) ||

View File

@ -177,8 +177,7 @@ png2vips_interlace( Read *read )
for( y = 0; y < (int) height; y++ )
read->row_pointer[y] = read->data + y * rowbytes;
if( vips_image_wio_output( read->out ) ||
setjmp( png_jmpbuf( read->pPng ) ) )
if( setjmp( png_jmpbuf( read->pPng ) ) )
return( -1 );
png_read_image( read->pPng, read->row_pointer );
@ -204,8 +203,7 @@ png2vips_noninterlace( Read *read )
if( !(read->data = (png_bytep) vips_malloc( NULL, rowbytes )) )
return( -1 );
if( vips_image_wio_output( read->out ) ||
setjmp( png_jmpbuf( read->pPng ) ) )
if( setjmp( png_jmpbuf( read->pPng ) ) )
return( -1 );
for( y = 0; y < height; y++ ) {

View File

@ -601,9 +601,6 @@ vips_image_generate( VipsImage *image,
g_assert( generate_fn );
g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) );
if( vips_image_pio_output( image ) )
return( -1 );
if( !image->hint_set ) {
vips_error( "vips_image_generate",
"%s", _( "demand hint not set" ) );

View File

@ -1638,7 +1638,6 @@ int
vips_image_write( VipsImage *image, VipsImage *out )
{
if( vips_image_pio_input( image ) ||
vips_image_pio_output( out ) ||
vips_image_copy_fields( out, image ) )
return( -1 );
vips_demand_hint( out,
@ -1817,6 +1816,9 @@ vips_image_write_line( VipsImage *image, int ypos, PEL *linebuffer )
/* Is this the start of eval?
*/
if( ypos == 0 ) {
if( vips_image_wio_output( image ) )
return( -1 );
/* Always clear kill before we start looping. See the
* call to vips_image_get_kill() below.
*/
@ -2051,21 +2053,17 @@ vips_image_wio_output( VipsImage *image )
*/
image->dtype = VIPS_IMAGE_SETBUF;
/* Fall through to SETBUF case.
*/
case VIPS_IMAGE_SETBUF:
if( image->data ) {
vips_error( "vips_image_wio_output",
"%s", _( "image already written" ) );
return( -1 );
}
break;
case VIPS_IMAGE_SETBUF:
case VIPS_IMAGE_OPENOUT:
case VIPS_IMAGE_SETBUF_FOREIGN:
/* Can write to this ok.
/* Can write to this ok.
*
* We used to check that ->data was null and warn about
* writing twice, but we no longer insist that this is called
* before vips__image_write_prepare(), so we can't do that any
* more.
*/
break;

View File

@ -1084,14 +1084,12 @@ vips_sink_screen( VipsImage *in, VipsImage *out, VipsImage *mask,
}
if( vips_image_pio_input( in ) ||
vips_image_pio_output( out ) ||
vips_image_copy_fields( out, in ) )
return( -1 );
vips_demand_hint( out, VIPS_DEMAND_STYLE_SMALLTILE, in, NULL );
if( mask ) {
if( vips_image_pio_output( mask ) ||
vips_image_copy_fields( mask, in ) )
if( vips_image_copy_fields( mask, in ) )
return( -1 );
vips_demand_hint( mask, VIPS_DEMAND_STYLE_SMALLTILE, in, NULL );