From 08255692634b240d528af25e488233957ca678b4 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 2 Nov 2007 16:37:32 +0000 Subject: [PATCH] man cleanups --- TODO | 3 + include/vips/internal.h | 1 + include/vips/threadgroup.h | 6 + include/vips/time.h | 19 --- include/vips/vips.h | 16 ++- libsrc/conversion/im_vips2jpeg.c | 50 ++++--- libsrc/iofuncs/Makefile.am | 1 + libsrc/iofuncs/im_generate.c | 25 +++- libsrc/iofuncs/im_wbuffer.c | 28 +--- man/IM_ARRAY.3 | 3 - man/IM_REGION_ADDR.3 | 2 - man/IM_RINT.3 | 2 - man/Makefile.am | 14 -- man/im_Lab2LabQ.3 | 2 - man/im_Lab2UCS.3 | 2 - man/im_LabQ2disp.3 | 2 - man/im_XYZ2disp.3 | 2 - man/im_col_XYZ2rgb.3 | 2 - man/im_dE_fromLab.3 | 2 - man/im_dE_fromdisp.3 | 2 - man/im_demand_hint.3 | 2 - man/im_error.3 | 1 - man/im_flood.3 | 1 - man/im_generate.3 | 2 - man/im_icc_transform.3 | 2 - man/im_iterate.3 | 2 - man/im_list_add.3 | 229 ------------------------------- man/im_list_append.3 | 1 - man/im_list_eq.3 | 1 - man/im_list_fix.3 | 1 - man/im_list_fold.3 | 1 - man/im_list_free.3 | 1 - man/im_list_index.3 | 1 - man/im_list_insert.3 | 1 - man/im_list_len.3 | 1 - man/im_list_map.3 | 1 - man/im_list_map_rev.3 | 1 - man/im_list_member.3 | 1 - man/im_list_pos.3 | 1 - man/im_list_remove.3 | 1 - man/im_malloc.3 | 26 ++-- man/im_open.3 | 4 +- man/im_paintrect.3 | 2 - man/im_prepare.3 | 2 - man/im_printdesc.3 | 2 - man/im_rect_marginadjust.3 | 2 - man/im_region_buffer.3 | 2 - man/im_region_create.3 | 2 - man/im_smudge.3 | 2 - man/im_wrapone.3 | 2 - 50 files changed, 95 insertions(+), 387 deletions(-) delete mode 100644 man/im_list_add.3 delete mode 100644 man/im_list_append.3 delete mode 100644 man/im_list_eq.3 delete mode 100644 man/im_list_fix.3 delete mode 100644 man/im_list_fold.3 delete mode 100644 man/im_list_free.3 delete mode 100644 man/im_list_index.3 delete mode 100644 man/im_list_insert.3 delete mode 100644 man/im_list_len.3 delete mode 100644 man/im_list_map.3 delete mode 100644 man/im_list_map_rev.3 delete mode 100644 man/im_list_member.3 delete mode 100644 man/im_list_pos.3 delete mode 100644 man/im_list_remove.3 diff --git a/TODO b/TODO index 1a6ceb8a..d404c051 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,6 @@ +- wrap API around the double-buffered write stuff and get + jpeg/tiff/png/ppm/etc. all writing double-buffered as well + - missing libstdc++ in link? what if we configure with no openexr? added -lstdc++ to VIPS_LIBS, but will this work on solaris etc.? maybe have diff --git a/include/vips/internal.h b/include/vips/internal.h index 185a6686..cea8d469 100644 --- a/include/vips/internal.h +++ b/include/vips/internal.h @@ -53,6 +53,7 @@ void *im__read_extension_block( IMAGE *im, int *size ); int im__readhist( IMAGE *image ); int im__write_extension_block( IMAGE *im, void *buf, int size ); int im__writehist( IMAGE *image ); +int im__handle_eval( IMAGE *im, int w, int h ); extern int im__read_test; extern int im__mmap_limit; diff --git a/include/vips/threadgroup.h b/include/vips/threadgroup.h index f55022fc..9c6359b8 100644 --- a/include/vips/threadgroup.h +++ b/include/vips/threadgroup.h @@ -127,6 +127,12 @@ void im_threadgroup_trigger( im_thread_t *thr ); */ int im_prepare_thread( im_threadgroup_t *tg, REGION *oreg, Rect *r ); +/* Threaded, double-buffered eval to file. + */ +typedef int (*im_wbuffer_fn)( REGION *region, Rect *area, void *a, void *b ); +int im_wbuffer( im_threadgroup_t *tg, + im_wbuffer_fn write_fn, void *a, void *b ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/include/vips/time.h b/include/vips/time.h index 5d073323..d8827039 100644 --- a/include/vips/time.h +++ b/include/vips/time.h @@ -36,25 +36,6 @@ extern "C" { #endif /*__cplusplus*/ -#include -#ifdef HAVE_SYS_TIME_H -#include -#endif /*HAVE_SYS_TIME_H*/ - -/* Struct we keep a record of execution time in. Passed to eval callback, so - * it can assess progress. - */ -struct time_info { - IMAGE *im; /* Image we are part of */ - time_t start; /* Start time, in seconds */ - int run; /* Time we have been running */ - int eta; /* Estimated seconds of computation left */ - gint64 tpels; /* Number of pels we expect to calculate */ - gint64 npels; /* Number of pels calculated so far */ - int percent; /* Percent complete */ -}; - -extern int im__handle_eval( IMAGE *im, int w, int h ); #ifdef __cplusplus } diff --git a/include/vips/vips.h b/include/vips/vips.h index 9305d55e..72ccaa50 100644 --- a/include/vips/vips.h +++ b/include/vips/vips.h @@ -231,6 +231,19 @@ typedef struct { size_t length; /* Size of window */ } im_window_t; +/* Struct we keep a record of execution time in. Passed to eval callback, so + * it can assess progress. + */ +typedef struct { + struct im__IMAGE *im; /* Image we are part of */ + GTimer *start; /* Start time */ + int run; /* Time we have been running */ + int eta; /* Estimated seconds of computation left */ + gint64 tpels; /* Number of pels we expect to calculate */ + gint64 npels; /* Number of pels calculated so far */ + int percent; /* Percent complete */ +} im_time_t; + /* Image descriptor for subroutine i/o args */ typedef struct im__IMAGE { @@ -256,7 +269,7 @@ typedef struct im__IMAGE { char *Hist; /* don't use ... call im_history_get() */ char *filename; /* pointer to copy of filename */ char *data; /* start of image data for WIO */ - struct time_info *time; /* time struct for eval callback */ + im_time_t *time; /* time struct for eval callback */ int kill; /* set to non-zero to block partial eval */ /* Private fields. @@ -455,6 +468,7 @@ typedef struct { #include #include #include +#include #ifdef __cplusplus } diff --git a/libsrc/conversion/im_vips2jpeg.c b/libsrc/conversion/im_vips2jpeg.c index 69f83d2c..3c20ce38 100644 --- a/libsrc/conversion/im_vips2jpeg.c +++ b/libsrc/conversion/im_vips2jpeg.c @@ -21,6 +21,8 @@ * - add eman.jmp ) ) + return( -1 ); + + for( i = 0; i < area->height; i++ ) + write->row_pointer[i] = (JSAMPROW) + IM_REGION_ADDR( region, 0, area->top + i ); + + jpeg_write_scanlines( &write->cinfo, write->row_pointer, area->height ); + + return( 0 ); +} + /* Write a VIPS image to a JPEG compress struct. */ static int @@ -522,9 +545,6 @@ write_vips( Write *write, int qfac, const char *profile ) { IMAGE *in = write->in; - Rect area; - int y, i; - /* Should have been converted for save. */ assert( in->BandFmt == IM_BANDFMT_UCHAR ); @@ -577,24 +597,16 @@ write_vips( Write *write, int qfac, const char *profile ) write_profile_meta( write ) ) return( -1 ); - /* Write data. + /* Write data. Note that the write function grabs the longjmp()! */ - for( y = 0; y < in->Ysize; y += write->tg->nlines ) { - area.left = 0; - area.top = y; - area.width = in->Xsize; - area.height = IM_MIN( write->tg->nlines, in->Ysize - y ); + if( im_wbuffer( write->tg, write_jpeg_block, write, NULL ) ) + return( -1 ); - if( im_prepare_thread( write->tg, write->reg, &area ) ) - return( -1 ); - - for( i = 0; i < area.height; i++ ) - write->row_pointer[i] = (JSAMPROW) - IM_REGION_ADDR( write->reg, 0, y + i ); - - jpeg_write_scanlines( &write->cinfo, - write->row_pointer, area.height ); - } + /* We have to reinstate the setjmp() before we jpeg_finish_compress(). + * No need to destroy the write: our parent does that. + */ + if( setjmp( write->eman.jmp ) ) + return( -1 ); jpeg_finish_compress( &write->cinfo ); diff --git a/libsrc/iofuncs/Makefile.am b/libsrc/iofuncs/Makefile.am index 84a4dc83..d5fe90a1 100644 --- a/libsrc/iofuncs/Makefile.am +++ b/libsrc/iofuncs/Makefile.am @@ -42,6 +42,7 @@ libiofuncs_la_SOURCES = \ im_unmapfile.c \ im_updatehist.c \ im_guess_prefix.c \ + im_wbuffer.c \ im_wrapmany.c \ im_wrapone.c \ im_writeline.c \ diff --git a/libsrc/iofuncs/im_generate.c b/libsrc/iofuncs/im_generate.c index 30e8d05c..e322d1f9 100644 --- a/libsrc/iofuncs/im_generate.c +++ b/libsrc/iofuncs/im_generate.c @@ -327,6 +327,28 @@ eval_to_memory( im_threadgroup_t *tg, REGION *or ) return( 0 ); } +/* A write function for VIPS images. Just write() the pixel data. + */ +static int +write_vips( REGION *region, Rect *area, void *a, void *b ) +{ + size_t nwritten, count; + void *buf; + + count = region->bpl * area->height; + buf = IM_REGION_ADDR( region, 0, area->top ); + do { + nwritten = write( region->im->fd, buf, count ); + if( nwritten == (size_t) -1 ) + return( errno ); + + buf = (void *) ((char *) buf + nwritten); + count -= nwritten; + } while( count > 0 ); + + return( 0 ); +} + /* Attach a generate function to an image. */ int @@ -402,8 +424,7 @@ im_generate( IMAGE *im, return( -1 ); } if( im->dtype == IM_OPENOUT ) - res = im_wbuffer( tg, - im_wbuffer_write_vips, NULL, NULL ); + res = im_wbuffer( tg, write_vips, NULL, NULL ); else res = eval_to_memory( tg, or ); diff --git a/libsrc/iofuncs/im_wbuffer.c b/libsrc/iofuncs/im_wbuffer.c index df39cb93..f0857f7f 100644 --- a/libsrc/iofuncs/im_wbuffer.c +++ b/libsrc/iofuncs/im_wbuffer.c @@ -75,32 +75,6 @@ typedef struct _WriteBuffer { void *b; } WriteBuffer; -/* A write function for VIPS images. Just write() the pixel data. - */ -int -im_wbuffer_write_vips( REGION *region, Rect *area, void *a, void *b ) -{ - size_t nwritten, count; - void *buf; - - count = region->bpl * area->height; - buf = IM_REGION_ADDR( region, 0, area->top ); - do { - nwritten = write( region->im->fd, buf, count ); - - /* Write failed? Note in wbuffer errno for the main - * thread to pick up. - */ - if( nwritten == (size_t) -1 ) - return( errno ); - - buf = (void *) ((char *) buf + nwritten); - count -= nwritten; - } while( count > 0 ); - - return( 0 ); -} - static void wbuffer_free( WriteBuffer *wbuffer ) { @@ -135,7 +109,7 @@ wbuffer_write( WriteBuffer *wbuffer ) #ifdef DEBUG printf( "wbuffer_write: %d bytes from wbuffer %p\n", - region->bpl * area->height, wbuffer ); + wbuffer->region->bpl * wbuffer->area.height, wbuffer ); #endif /*DEBUG*/ } diff --git a/man/IM_ARRAY.3 b/man/IM_ARRAY.3 index 2ed9a74b..4e3c9942 100644 --- a/man/IM_ARRAY.3 +++ b/man/IM_ARRAY.3 @@ -4,8 +4,6 @@ IM_ARRAY, IM_NEW, IM_NUMBER \- memory allocation macros .SH SYNOPSIS #include -.br -#include type-name *IM_NEW( IMAGE *im, type-name ) .br @@ -41,7 +39,6 @@ Both functions return NULL on error, setting im_errorstring. Example: #include - #include /* A structure we want to carry about. */ diff --git a/man/IM_REGION_ADDR.3 b/man/IM_REGION_ADDR.3 index 206f8c0a..a84a3305 100644 --- a/man/IM_REGION_ADDR.3 +++ b/man/IM_REGION_ADDR.3 @@ -6,8 +6,6 @@ IM_REGION_N_ELEMENTS, IM_REGION_SIZEOF_LINE \- macros for regions .SH SYNOPSIS .B #include -.br -.B #include int IM_REGION_LSKIP( reg ) .br diff --git a/man/IM_RINT.3 b/man/IM_RINT.3 index 210c399c..5caa8ec0 100644 --- a/man/IM_RINT.3 +++ b/man/IM_RINT.3 @@ -4,8 +4,6 @@ IM_RINT, IM_MAX, IM_MIN \- misc math macros .SH SYNOPSIS .B #include -.br -.B #include int IM_RINT( float ) .br diff --git a/man/Makefile.am b/man/Makefile.am index 4624358d..0cbdb961 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -303,20 +303,6 @@ man_MANS = \ im_lineset.3 \ im_lintra.3 \ im_lintra_vec.3 \ - im_list_add.3 \ - im_list_append.3 \ - im_list_eq.3 \ - im_list_fix.3 \ - im_list_fold.3 \ - im_list_free.3 \ - im_list_index.3 \ - im_list_insert.3 \ - im_list_len.3 \ - im_list_map.3 \ - im_list_map_rev.3 \ - im_list_member.3 \ - im_list_pos.3 \ - im_list_remove.3 \ im_litecor.3 \ im_log10tra.3 \ im_log_dmask.3 \ diff --git a/man/im_Lab2LabQ.3 b/man/im_Lab2LabQ.3 index 97ddbcbb..02106cc1 100644 --- a/man/im_Lab2LabQ.3 +++ b/man/im_Lab2LabQ.3 @@ -3,8 +3,6 @@ im_LabQ2Lab, im_Lab2LabQ, im_LabQ2LabS, im_LabS2LabQ, im_Lab2LabS, im_LabS2Lab \- pack and unpack LABPACK images. .SH SYNOPSIS #include -.br -#include int im_LabQ2Lab(in, out) .br diff --git a/man/im_Lab2UCS.3 b/man/im_Lab2UCS.3 index df1c0963..3972526e 100644 --- a/man/im_Lab2UCS.3 +++ b/man/im_Lab2UCS.3 @@ -4,8 +4,6 @@ im_Lab2UCS, im_LabQ2XYZ, im_UCS2Lab, im_Lab2disp, im_disp2Lab, im_UCS2XYZ, im_XYZ2UCS \- derived colour space conversion functions .SH SYNOPSIS #include -.br -#include int im_Lab2UCS(in, out) .br diff --git a/man/im_LabQ2disp.3 b/man/im_LabQ2disp.3 index 0743fe39..6be15c62 100644 --- a/man/im_LabQ2disp.3 +++ b/man/im_LabQ2disp.3 @@ -3,8 +3,6 @@ im_LabQ2disp, im_LabQ2disp_build_table, im_LabQ2disp_table \- convert LabQ to display rgb quickly and badly .SH SYNOPSIS #include -.br -#include int im_LabQ2disp( IMAGE *in, IMAGE *out, struct im_col_display *d ); diff --git a/man/im_XYZ2disp.3 b/man/im_XYZ2disp.3 index 3bfe3879..409c5ad0 100644 --- a/man/im_XYZ2disp.3 +++ b/man/im_XYZ2disp.3 @@ -6,8 +6,6 @@ im_Lab2LCh, im_LCh2Lab, im_LCh2UCS, im_UCS2LCh \- convert images between various colour spaces .SH SYNOPSIS #include -.br -#include int im_XYZ2disp(in, out, display) .br diff --git a/man/im_col_XYZ2rgb.3 b/man/im_col_XYZ2rgb.3 index 6c273ff2..475c312b 100644 --- a/man/im_col_XYZ2rgb.3 +++ b/man/im_col_XYZ2rgb.3 @@ -7,8 +7,6 @@ im_col_Chucs2h, im_col_make_tables_UCS, im_col_dECMC \- colour space conversion .SH SYNOPSIS #include -.br -#include int im_col_ab2Ch( a, b, C, h ) diff --git a/man/im_dE_fromLab.3 b/man/im_dE_fromLab.3 index e8c0291c..46de25af 100644 --- a/man/im_dE_fromLab.3 +++ b/man/im_dE_fromLab.3 @@ -3,8 +3,6 @@ im_dE_fromLab, im_dECMC_fromLab, im_dE00_fromLab \- calculate colour differences .SH SYNOPSIS #include -.br -#include int im_dE_fromLab(in1, in2, out) .br diff --git a/man/im_dE_fromdisp.3 b/man/im_dE_fromdisp.3 index 02ae7763..5aa32c15 100644 --- a/man/im_dE_fromdisp.3 +++ b/man/im_dE_fromdisp.3 @@ -4,8 +4,6 @@ im_dE_fromdisp, im_dE_fromXYZ, im_dECMC_fromdisp \- derived colour difference functions .SH SYNOPSIS #include -.br -#include im_dE_fromdisp( in1, in2, out, display ) .br diff --git a/man/im_demand_hint.3 b/man/im_demand_hint.3 index 0b7623e0..383afa75 100644 --- a/man/im_demand_hint.3 +++ b/man/im_demand_hint.3 @@ -3,8 +3,6 @@ im_demand_hint \- hint on demand style for im_generate(3) .SH SYNOPSIS #include -.br -#include int im_demand_hint( im, hint, in1, in2, ..., NULL ) .br diff --git a/man/im_error.3 b/man/im_error.3 index 884328a5..71df1cb9 100644 --- a/man/im_error.3 +++ b/man/im_error.3 @@ -4,7 +4,6 @@ im_error_buffer, im_verror, im_error, im_error_clear, im_warn, im_diag, error_exit \- handle error messages from VIPS .SH SYNOPSIS .B #include -.B #include .B const char *im_error_buffer( void ) diff --git a/man/im_flood.3 b/man/im_flood.3 index a261e53e..87cc3fa5 100644 --- a/man/im_flood.3 +++ b/man/im_flood.3 @@ -3,7 +3,6 @@ im_flood, im_flood_blob \- flood a area .SH SYNOPSIS .B #include -.B #include int im_flood( im, x, y, ink, dout ) .br diff --git a/man/im_generate.3 b/man/im_generate.3 index 2c5ed1ca..44da8482 100644 --- a/man/im_generate.3 +++ b/man/im_generate.3 @@ -4,8 +4,6 @@ im_generate, im_start_one, im_stop_one, im_allocate_input_array, im_start_many, im_stop_many \- generate image pixels .SH SYNOPSIS .B #include -.br -.B #include void *im_start_one( out, in ) .br diff --git a/man/im_icc_transform.3 b/man/im_icc_transform.3 index 24eae259..c473febe 100644 --- a/man/im_icc_transform.3 +++ b/man/im_icc_transform.3 @@ -5,8 +5,6 @@ im_icc_export, im_icc_export_depth \- transform images using ICC profiles .SH SYNOPSIS #include -.br -#include #define VIPS_INTENT_PERCEPTUAL (0) .br diff --git a/man/im_iterate.3 b/man/im_iterate.3 index 1735b64e..d777ce73 100644 --- a/man/im_iterate.3 +++ b/man/im_iterate.3 @@ -3,8 +3,6 @@ im_iterate \- PIO input from image .SH SYNOPSIS .B #include -.br -.B #include int im_iterate( im, start_fn, scan_fn, stop_fn, a, b ) .br diff --git a/man/im_list_add.3 b/man/im_list_add.3 deleted file mode 100644 index 1f901b08..00000000 --- a/man/im_list_add.3 +++ /dev/null @@ -1,229 +0,0 @@ -.TH IM_LIST_ADD 3 "2 May 1991" -.SH NAME -im_list_add, im_list_len, im_list_pos, im_list_member, im_list_append, -im_list_remove, -im_list_eq, im_list_map, im_list_map_rev, im_list_fold, im_list_fix, -im_list_free, im_list_insert \- linked list functions -.SH SYNOPSIS -#include -.br -#include - -typedef struct list_type { -.br - struct list_type *next; -.br - void *this; -.br -} List; - -#define hd(L) ((L)->this) -.br -#define tl(L) ((L)->next) - -typedef void *(*im_list_map_fn)( void *, void *, void * ); -.br -typedef void (*im_list_free_fn)( void *, void *, void * ); -.br -typedef void *(*im_list_fold_fn)( void *, void *, -.br - void *, void * ); - -int im_list_len( List *l ); -.br -int im_list_pos( List *l, void *t ); -.br -int im_list_member( List *l, void *t ); -.br -void *im_list_index( List *l, int n ); -.br -int im_list_add( List **base, void *new ); -.br -int im_list_insert( List **base, void *new, void *old ); -.br -int im_list_append( List **base, void *new ); -.br -int im_list_remove( List **base, void *t ); - -void *im_list_eq( void *a, void *b ); -.br -void *im_list_map( List *l, -.br - im_list_map_fn fn, void *a, void *b ); -.br -void *im_list_map_rev( List *l, -.br - im_list_map_fn fn, void *a, void *b ); -.br -void *im_list_fold( List *l, -.br - void *start, im_list_fold_fn fn, void *a, void *b ); -.br -void im_list_fix( List **base, -.br - im_list_map_fn fn, void *a, void *b ); -.br -void im_list_free( List **base, -.br - im_list_free_fn fn, void *a, void *b ); - -.SH DESCRIPTION -Manipulate linked lists in various ways. These functions are heavily used by -the VIPS IO system; use them yourself if you like. VIPS lists store lists of -void * pointers - use casts if you want to store some other type. Note that -if sizeof( your object ) != sizeof( void * ), you will be in trouble! - -All are based on the List type (see above). An empty list is a NULL pointer, a -one element list is a pointer to a List struct, whose this field contains a -pointer to the object in the list and whose next field is NULL. Macros hd(3) -and tl(3) (head and tail) return this and next respectively. - -im_list_len(3) returns the number of elements in list l. im_list_pos(3) searches -list l for stored object t, returning an index. The first list element has -index zero. im_list_pos(3) returns -1 for not present. im_list_index(3) returns -the item at position n in the list, or NULL for index out of range. -im_list_member(3) returns non-zero if the list contains the element. - -im_list_map(3) applies a void * valued function to every element in a list, -running from beginning to end. If the function returns NULL, im_list_map -continues with the next element. If the function returns non-NULL, -im_list_map(3) abandons the map and returns immediately, returning the value -the user function returned. If the list is empty, im_list_map(3) returns NULL. - -The two extra arguments a and b are carried around for you by VIPS and fed -into each call of the function. They are useful for communicating context -information. - -You can use im_list_map to implement many kinds of list search/apply operation. -VIPS supplies the function im_list_eq(3) which tests two void * pointers for -equality, returning the pointer if they match, and returning NULL otherwise. - -Example: search a list for an object - - im_list_map( list, -.br - (im_list_map_fn) im_list_eq, object, NULL ); - -This could also be written as - - List *p; - - for( p = list; p; p = tl( p ) ) -.br - if( object == hd( p ) ) -.br - break; - -I prefer the first. - -im_list_map_rev(3) behaves exactly as im_list_map(3), but applies the function -running from te end to the beginning of the list. It is much slower than -im_list_map(3) and should be used only in emergencies. - -im_list_fold(3) folds up a list with a dyadic function. If a list contains -[1,2], return fn( 2, fn( 1, start, a, b ), a, b ). If the list is empty, -return start. - -The two extra arguments a and b are carried around for you by VIPS and fed -into each call of the function. They are useful for communicating context -information. - -Example: find a pointer to the largest element in a list of ints (assume -sizeof(int) <= sizeof(void *)) - - max_pair( int *new, int *old ) -.br - { -.br - if( !old || *new > *old ) -.br - return( new ); -.br - else -.br - return( old ); -.br - } - - largest = im_list_fold( list, -.br - NULL, (im_list_map_fn) max_pair, NULL, NULL ); - -im_list_add(3) adds a new element to the head of a list. Since the head of the -list will move, you must pass in a *pointer* to your pointer to your old head. - -Example: make a list of the numbers 9-0 (assume sizeof(int) <= sizeof(void *)) - - int i; -.br - List *nlist = NULL; - - for( i = 0; i < 10; i++ ) -.br - im_list_add( &nlist, (void *) i ); - -im_list_insert(3) adds a new element to a list, placing it just before the -indicated old element. If the old element is not found, im_list_insert(3) -returns an error. - -im_list_append(3) appends a new element to the end of a list. This is much -slower than im_list_add(3), and should be avoided if possible. - -im_list_remove(3) removes the specified element from the list. Since the head -of the list may move, you must pass in a *pointer* to your pointer to your -old head. - -im_list_fix(3) finds the fixed-point of a list-altering function. It repeatedly -maps a function over the list until the function returns NULL. Note that, -since the list may be changing, you must pass in a *pointer* to the pointer -you store the list in. - -The two extra arguments a and b are carried around for you by VIPS and fed -into each call of the function. They are useful for communicating context -information. - -Example: remove all elements less than x from a list of numbers (assume -sizeof(int) <= sizeof(void *)) - - int * -.br - test_ele( int *n, List **base, int x ) -.br - { -.br - if( *n < x ) { -.br - im_list_remove( base, n ); -.br - return( base ); -.br - } -.br - else -.br - return( NULL ); -.br - } - - im_list_fix( &nlist, -.br - (im_list_map_fn) test_ele, &nlist, x ); - -im_list_free(3) frees the list, applying a user free function to every element -as it is freed. You may pass NULL instead of a pointer to a function, in which -case im_list_free(3) will just free the memory used by the list nodes. - -The two extra arguments a and b are carried around for you by VIPS and fed -into each call of the function. They are useful for communicating context -information. - -.SH RETURN VALUE -The functions returns a 0 or a pointer on sucess, and non-zero or NULL on -failure. -.SH SEE\ ALSO -im_rect_intersectrect(3), etc. -.SH COPYRIGHT -.br -National Gallery, 1992 -.SH AUTHOR -J. Cupitt diff --git a/man/im_list_append.3 b/man/im_list_append.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_append.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_eq.3 b/man/im_list_eq.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_eq.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_fix.3 b/man/im_list_fix.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_fix.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_fold.3 b/man/im_list_fold.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_fold.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_free.3 b/man/im_list_free.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_free.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_index.3 b/man/im_list_index.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_index.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_insert.3 b/man/im_list_insert.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_insert.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_len.3 b/man/im_list_len.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_len.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_map.3 b/man/im_list_map.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_map.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_map_rev.3 b/man/im_list_map_rev.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_map_rev.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_member.3 b/man/im_list_member.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_member.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_pos.3 b/man/im_list_pos.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_pos.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_list_remove.3 b/man/im_list_remove.3 deleted file mode 100644 index 2299eb96..00000000 --- a/man/im_list_remove.3 +++ /dev/null @@ -1 +0,0 @@ -.so man3/im_list_add.3 diff --git a/man/im_malloc.3 b/man/im_malloc.3 index ed13b2c4..bb2f0cd5 100644 --- a/man/im_malloc.3 +++ b/man/im_malloc.3 @@ -32,8 +32,6 @@ char *im_malloc( IMAGE *im, int size ); int im_free( void *s ); .B #include -.br -.B #include int im_add_eval_callback( im, fn, a, b ) .br @@ -107,19 +105,19 @@ the image is written to. This works for both PIO and WIO images, although it is rather more successful with PIO image output. When the callback is triggered, the time field of the descriptor will point to -a time_info structure, as defined in +a +.B im_time_t +structure, see vips.h - #include - - struct time_info { - IMAGE *im; /* Image we are part of */ - time_t start; /* Start time, in seconds */ - int run; /* Time we have been running */ - int eta; /* Seconds of computation left */ - int ttiles; /* Tiles we expect to calculate */ - int ntiles; /* Tiles calculated so far */ - int percent; /* Percent complete */ - }; + typedef struct { + IMAGE *im; /* Image we are part of */ + GTimer *start; /* Start time */ + int run; /* Time we have been running (secs) */ + int eta; /* Estimated seconds of computation left */ + gint64 tpels; /* Number of pels we expect to calculate */ + gint64 npels; /* Number of pels calculated so far */ + int percent; /* Percent complete */ + } im_time_t; These fields are not exact! They should only be used to give approximate feedback to the user. It is possible to have diff --git a/man/im_open.3 b/man/im_open.3 index ddb9379e..726bd593 100644 --- a/man/im_open.3 +++ b/man/im_open.3 @@ -78,7 +78,6 @@ calls to escape points. Example: find the total of an array of images. #include - #include int total( IMAGE **in, int nin, IMAGE *out ) @@ -111,7 +110,8 @@ This function will create many intermediate images, but does not need to close them. Any which are created will be closed automatically when out is closed by our caller. -im_open_local(3) returns NULL on error, or if its first parameter is NULL. +.B im_open_local(3) +returns NULL on error, or if its first parameter is NULL. .B im_open_local_array(3) will open an array of images, failing if any of the opens fail. It's handy if diff --git a/man/im_paintrect.3 b/man/im_paintrect.3 index 2c9381d6..812dd46d 100644 --- a/man/im_paintrect.3 +++ b/man/im_paintrect.3 @@ -4,8 +4,6 @@ im_paintrect, im_plotmask, im_readpoint, im_plotpoint, im_fastline, im_fastlineuser \- suck pels up, and paint them down somewhere else .SH SYNOPSIS .B #include -.br -.B #include int im_readpoint( im, x, y, ink ) .br diff --git a/man/im_prepare.3 b/man/im_prepare.3 index 49297a1c..e1f5357f 100644 --- a/man/im_prepare.3 +++ b/man/im_prepare.3 @@ -3,8 +3,6 @@ im_prepare, im_prepare_to \- fill region with data .SH SYNOPSIS .B #include -.br -.B #include int im_prepare( reg, r ) .br diff --git a/man/im_printdesc.3 b/man/im_printdesc.3 index 9a94b602..240e79c7 100644 --- a/man/im_printdesc.3 +++ b/man/im_printdesc.3 @@ -6,8 +6,6 @@ im_Coding2char, im_char2Coding, im_Compression2char, im_char2Compression .SH SYNOPSIS .B #include -.br -.B #include .B void im_printdesc(image) .br diff --git a/man/im_rect_marginadjust.3 b/man/im_rect_marginadjust.3 index 32ea226e..488e2f34 100644 --- a/man/im_rect_marginadjust.3 +++ b/man/im_rect_marginadjust.3 @@ -7,8 +7,6 @@ IM_RECT_RIGHT, IM_RECT_BOTTOM, IM_RECT_HCENTRE, IM_RECT_VCENTRE \- rectangle algebra functions .SH SYNOPSIS #include -.br -#include typedef struct { .br diff --git a/man/im_region_buffer.3 b/man/im_region_buffer.3 index 97d5afb9..327feefe 100644 --- a/man/im_region_buffer.3 +++ b/man/im_region_buffer.3 @@ -5,8 +5,6 @@ im_region_equalsregion \- attach data to region .SH SYNOPSIS .B #include -.br -.B #include int im_region_buffer( reg, r ) .br diff --git a/man/im_region_create.3 b/man/im_region_create.3 index 25335c80..b05fb735 100644 --- a/man/im_region_create.3 +++ b/man/im_region_create.3 @@ -3,8 +3,6 @@ im_region_create, im_region_free \- region creation and destruction .SH SYNOPSIS .B #include -.br -.B #include REGION *im_region_create( im ) .br diff --git a/man/im_smudge.3 b/man/im_smudge.3 index d7825ca4..878cd645 100644 --- a/man/im_smudge.3 +++ b/man/im_smudge.3 @@ -3,8 +3,6 @@ im_smudge, im_smear \- filter and smudge in place .SH SYNOPSIS .B #include -.br -.B #include int .br diff --git a/man/im_wrapone.3 b/man/im_wrapone.3 index 9235bb45..09589f06 100644 --- a/man/im_wrapone.3 +++ b/man/im_wrapone.3 @@ -3,8 +3,6 @@ im_wrapone, im_wrapmany \- easy interface to partial image IO system .SH SYNOPSIS .B #include -.br -.B #include int im_wrapone( IMAGE *in, IMAGE *out, im_wrapone_fn fn, void *a, void *b )