From 49d3542cc77766f328eebfc0d074120a88ad44b1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 21 Dec 2011 19:00:32 +0000 Subject: [PATCH] remove outchecks, again --- ChangeLog | 1 + TODO | 11 +------- libvips/foreign/openslide2vips.c | 2 +- libvips/include/vips/image.h | 9 +++---- libvips/include/vips/private.h | 5 ++-- libvips/include/vips/vips7compat.h | 10 ++++---- libvips/iofuncs/generate.c | 4 +-- libvips/iofuncs/image.c | 40 ++++++++++++++---------------- 8 files changed, 34 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75de4804..139d40ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -64,6 +64,7 @@ - allow new-style load/save options in filenames to vips_image_new_from_file() etc. - VipsFormat is deprecated +- remove outchecks from documented API 12/10/11 started 7.26.6 - NOCACHE was not being set correctly on OS X causing performance diff --git a/TODO b/TODO index cc2cdc94..f6ff981b 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,4 @@ -- 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() - - +- foreign docs diff --git a/libvips/foreign/openslide2vips.c b/libvips/foreign/openslide2vips.c index 5d694962..d50724c9 100644 --- a/libvips/foreign/openslide2vips.c +++ b/libvips/foreign/openslide2vips.c @@ -334,7 +334,7 @@ vips__openslide_read_associated( const char *filename, VipsImage *out, vips_object_local( out, raw ); if( !(rslide = readslide_new( filename, raw, 0, associated )) || - vips_image_wio_output( raw ) ) + vips_image_write_prepare( raw ) ) return( -1 ); openslide_read_associated_image( rslide->osr, rslide->associated, (uint32_t *) VIPS_IMAGE_ADDR( raw, 0, 0 ) ); diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index 57ecb752..599a7a2c 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -488,13 +488,12 @@ gboolean vips_image_isMSBfirst( VipsImage *image ); gboolean vips_image_isfile( VipsImage *image ); gboolean vips_image_ispartial( VipsImage *image ); -int vips_image_write_line( VipsImage *image, int ypos, PEL *linebuffer ); - int vips_image_wio_input( VipsImage *image ); -int vips_image_wio_output( VipsImage *image ); -int vips_image_inplace( VipsImage *image ); int vips_image_pio_input( VipsImage *image ); -int vips_image_pio_output( VipsImage *image ); +int vips_image_inplace( VipsImage *image ); +int vips_image_write_prepare( VipsImage *image ); + +int vips_image_write_line( VipsImage *image, int ypos, PEL *linebuffer ); gboolean vips_band_format_isint( VipsBandFormat format ); gboolean vips_band_format_isuint( VipsBandFormat format ); diff --git a/libvips/include/vips/private.h b/libvips/include/vips/private.h index 2977cdf1..1793c8c9 100644 --- a/libvips/include/vips/private.h +++ b/libvips/include/vips/private.h @@ -157,9 +157,8 @@ typedef int (*VipsRegionFillFn)( struct _VipsRegion *, void * ); int vips_region_fill( struct _VipsRegion *reg, VipsRect *r, VipsRegionFillFn fn, void *a ); -/* The new name for im_setupout(), still used by some old code. - */ -int vips__image_write_prepare( struct _VipsImage *image ); +int vips__image_wio_output( struct _VipsImage *image ); +int vips__image_pio_output( struct _VipsImage *image ); #ifdef __cplusplus } diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index afb191a3..57086a9c 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -170,7 +170,7 @@ extern "C" { type, xres, yres ) #define im__open_image_file vips__open_image_read -#define im_setupout( I ) vips__image_write_prepare( I ) +#define im_setupout( I ) (0) #define im_writeline( Y, IM, P ) vips_image_write_line( IM, Y, P ) #define im_prepare vips_region_prepare @@ -326,13 +326,13 @@ G_STMT_START { \ #define IM_ARRAY( IM, N, T ) ((T *) im_malloc( (IM), (N) * sizeof( T ))) #define im_incheck vips_image_wio_input -#define im_outcheck vips_image_wio_output +#define im_outcheck( I ) (0) #define im_rwcheck vips_image_inplace #define im_pincheck vips_image_pio_input -#define im_poutcheck vips_image_pio_output +#define im_poutcheck( I ) (0) -#define im_iocheck( I, O ) (im_incheck( I ) || im_outcheck( O )) -#define im_piocheck( I, O ) (im_pincheck( I ) || im_poutcheck( O )) +#define im_iocheck( I, O ) im_incheck( I ) +#define im_piocheck( I, O ) im_pincheck( I ) #define im_check_uncoded vips_check_uncoded #define im_check_coding_known vips_check_coding_known diff --git a/libvips/iofuncs/generate.c b/libvips/iofuncs/generate.c index a5ee7210..d74e70e8 100644 --- a/libvips/iofuncs/generate.c +++ b/libvips/iofuncs/generate.c @@ -659,9 +659,7 @@ vips_image_generate( VipsImage *image, image->client1 = a; image->client2 = b; - /* Get output ready. - */ - if( vips__image_write_prepare( image ) ) + if( vips_image_write_prepare( image ) ) return( -1 ); if( image->dtype == VIPS_IMAGE_OPENOUT ) diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index a87e942a..9b819206 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -1539,7 +1539,7 @@ vips_image_new_array( int xsize, int ysize ) return( NULL ); } - if( vips__image_write_prepare( image ) ) { + if( vips_image_write_prepare( image ) ) { g_object_unref( image ); return( NULL ); } @@ -1737,12 +1737,21 @@ vips_image_ispartial( VipsImage *image ) return( 0 ); } -/* Get the image ready for writing. This can get called many - * times. Used by vips_image_generate() and vips_image_write_line(). vips7 - * compat can call this as im_setupout(). +/** + * vips_image_write_prepare: + * @image: image to prepare + * + * Call this after setting header fields (width, height, and so on) to + * allocate resources ready for writing. + * + * Normally this function is called for you by vips_image_generate() or + * vips_image_write_line(). You will need to call it yourself if you plan to + * write directly to the ->data member of a "t" image. + * + * Returns: 0 on success, or -1 on error. */ int -vips__image_write_prepare( VipsImage *image ) +vips_image_write_prepare( VipsImage *image ) { g_assert( vips_object_sanity( VIPS_OBJECT( image ) ) ); @@ -1759,7 +1768,7 @@ vips__image_write_prepare( VipsImage *image ) image->Bbits = vips_format_sizeof( image->BandFmt ) << 3; if( image->dtype == VIPS_IMAGE_PARTIAL ) { - VIPS_DEBUG_MSG( "vips__image_write_prepare: " + VIPS_DEBUG_MSG( "vips_image_write_prepare: " "old-style output for %s\n", image->filename ); image->dtype = VIPS_IMAGE_SETBUF; @@ -1816,14 +1825,14 @@ 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 ) ) + if( vips__image_wio_output( image ) ) return( -1 ); /* Always clear kill before we start looping. See the * call to vips_image_get_kill() below. */ vips_image_set_kill( image, FALSE ); - vips__image_write_prepare( image ); + vips_image_write_prepare( image ); vips_image_preeval( image ); } @@ -2020,19 +2029,8 @@ vips_image_wio_input( VipsImage *image ) return( 0 ); } -/** - * vips_image_wio_output: - * @image: image to check - * - * Check that an image is writeable by vips_image_write_line(). If it isn't, - * try to transform it so that vips_image_write_line() can work. - * - * See also: vips_image_wio_input(). - * - * Returns: 0 on succeess, or -1 on error. - */ int -vips_image_wio_output( VipsImage *image ) +vips__image_wio_output( VipsImage *image ) { #ifdef DEBUG_IO printf( "vips_image_wio_output: WIO output for %s\n", @@ -2062,7 +2060,7 @@ vips_image_wio_output( VipsImage *image ) * * 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 + * before vips_image_write_prepare(), so we can't do that any * more. */ break;