From a338a48c63c6b71bdcc4b00a4ea8c714b2ab4de4 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 25 Jul 2014 13:52:36 +0100 Subject: [PATCH 1/4] fix a race in im_maxpos_avg() --- ChangeLog | 3 +++ TODO | 26 -------------------------- configure.ac | 6 +++--- libvips/deprecated/im_maxpos_avg.c | 7 +++++++ 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index a169db41..17ad31e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +25/7/14 started 7.40.5 +- fix a race in im_maxpos_avg() + 4/7/14 started 7.40.4 - fix vips_rawsave_fd(), thanks aferrero2707 - fix im_point() diff --git a/TODO b/TODO index 31a7f8c5..0475cf41 100644 --- a/TODO +++ b/TODO @@ -1,30 +1,4 @@ -- maxpos_avg seems to give variable results - - irb(main):022:0> im.maxpos_avg - => [141.0, 138.0, 248.0] - irb(main):023:0> im.maxpos_avg - => [73.0, 95.0, 248.0] - - [107.0, 116.5, 248.0] is correct, checked by hand - -$ vips max --size 10 spec/samples/wagon.v --x-array --y-array --out-array -72 107 78 73 74 75 99 100 141 73 -95 141 94 94 94 95 131 131 138 95 -245 246 246 247 247 247 247 247 248 248 -248.000000 - - so there are two maxes of 248, result should be average of the two - - seems to be a race in maxpos_avg, it's still some Tom code, replace with a - wrapper over vips_max() - - hard to do, since vips_max() needs to be told in advance the number of maxes - it should search for - - - - - threadpool recyling might be useful for dzsave? diff --git a/configure.ac b/configure.ac index f408befe..e9327fff 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [7.40.4], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [7.40.5], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [7]) m4_define([vips_minor_version], [40]) -m4_define([vips_micro_version], [4]) +m4_define([vips_micro_version], [5]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date` # binary interface changes not backwards compatible?: reset age to 0 LIBRARY_CURRENT=38 -LIBRARY_REVISION=2 +LIBRARY_REVISION=3 LIBRARY_AGE=0 # patched into include/vips/version.h diff --git a/libvips/deprecated/im_maxpos_avg.c b/libvips/deprecated/im_maxpos_avg.c index f62a0477..0d7f0417 100644 --- a/libvips/deprecated/im_maxpos_avg.c +++ b/libvips/deprecated/im_maxpos_avg.c @@ -15,6 +15,8 @@ * 8/9/08 * - rewrite from im_maxpos() * - now handles many bands, complex, faster + * 27/7/14 + * - fix a race ... did not merge states if max was equal */ /* @@ -116,6 +118,11 @@ maxposavg_stop( void *seq, void *a, void *b ) */ if( maxposavg->max > global_maxposavg->max ) *global_maxposavg = *maxposavg; + else if( maxposavg->max == global_maxposavg->max ) { + global_maxposavg->xpos += maxposavg->xpos; + global_maxposavg->ypos += maxposavg->ypos; + global_maxposavg->occurences += maxposavg->occurences; + } im_free( seq ); From 91cb6cd8c464f1430832b1b111e6617eb2d2e603 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 25 Jul 2014 14:13:33 +0100 Subject: [PATCH 2/4] remove an old comment --- libvips/iofuncs/threadpool.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/libvips/iofuncs/threadpool.c b/libvips/iofuncs/threadpool.c index 212868b4..00b3f0c1 100644 --- a/libvips/iofuncs/threadpool.c +++ b/libvips/iofuncs/threadpool.c @@ -344,24 +344,6 @@ vips_concurrency_get( void ) return( nthr ); } -/** - * VipsThreadState: - * @im: the #VipsImage being operated upon - * @reg: a #REGION - * @pos: a #Rect - * @x: an int - * @y: an int - * @a: client data - * - * These per-thread values are carried around for your use by - * vips_threadpool_run(). They are private to each thread, so they are a - * useful place - * for #VipsThreadpoolAllocate and #VipsThreadpoolWork to communicate. - * - * @reg is created for you at the start of processing and freed at the end, - * but you can do what you like with it. - */ - G_DEFINE_TYPE( VipsThreadState, vips_thread_state, VIPS_TYPE_OBJECT ); static void From 0114afa5fb07f994cea4f72cc72794c52e13769a Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 25 Jul 2014 14:51:29 +0100 Subject: [PATCH 3/4] limit nthr on tiny images we always made N threads for a threadpool ... we could end up making loads of threads we never used if the image was tiny for very small images, limit the number of threads we make --- ChangeLog | 1 + TODO | 2 -- libvips/iofuncs/threadpool.c | 32 +++++++++++++++++++++++--------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17ad31e3..507eca71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 25/7/14 started 7.40.5 - fix a race in im_maxpos_avg() +- limit n_thr on tiny images 4/7/14 started 7.40.4 - fix vips_rawsave_fd(), thanks aferrero2707 diff --git a/TODO b/TODO index 0475cf41..3c84c9aa 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,4 @@ -- threadpool recyling might be useful for dzsave? - - check and fix up docs diff --git a/libvips/iofuncs/threadpool.c b/libvips/iofuncs/threadpool.c index 00b3f0c1..84b5ebe3 100644 --- a/libvips/iofuncs/threadpool.c +++ b/libvips/iofuncs/threadpool.c @@ -13,6 +13,8 @@ * 17/7/10 * - set pool->error whenever we set thr->error, lets us catch allocate * errors (thanks Tim) + * 25/7/14 + * - limit nthr on tiny images */ /* @@ -688,6 +690,10 @@ static VipsThreadpool * vips_threadpool_new( VipsImage *im ) { VipsThreadpool *pool; + int tile_width; + int tile_height; + int n_tiles; + int n_lines; /* Allocate and init new thread block. */ @@ -705,6 +711,14 @@ vips_threadpool_new( VipsImage *im ) pool->stop = FALSE; pool->done_first = FALSE; + /* If this is a tiny image, we won't need all nthr threads. Guess how + * many tiles we might need to cover the image and use that to limit + * the number of threads we create. + */ + vips_get_tile_size( im, &tile_width, &tile_height, &n_lines ); + n_tiles = (1 + im->Xsize / tile_width) * (1 + im->Ysize / tile_height); + pool->nthr = VIPS_MIN( pool->nthr, n_tiles ); + /* Attach tidy-up callback. */ g_signal_connect( im, "close", @@ -919,7 +933,7 @@ vips_threadpool_run( VipsImage *im, * @im: image to guess for * @tile_width: return selected tile width * @tile_height: return selected tile height - * @nlines: return buffer height in scanlines + * @n_lines: return buffer height in scanlines * * Pick a tile size and a buffer height for this image and the current * value of vips_concurrency_get(). The buffer height @@ -927,7 +941,7 @@ vips_threadpool_run( VipsImage *im, */ void vips_get_tile_size( VipsImage *im, - int *tile_width, int *tile_height, int *nlines ) + int *tile_width, int *tile_height, int *n_lines ) { const int nthr = vips_concurrency_get(); @@ -954,25 +968,25 @@ vips_get_tile_size( VipsImage *im, g_assert( 0 ); } - /* We can't set nlines for the current demand style: a later bit of + /* We can't set n_lines for the current demand style: a later bit of * the pipeline might see a different hint and we need to synchronise * buffer sizes everywhere. * * Pick the maximum buffer size we might possibly need, then round up * to a multiple of tileheight. */ - *nlines = vips__tile_height * + *n_lines = vips__tile_height * (1 + nthr / VIPS_MAX( 1, im->Xsize / vips__tile_width )) * 2; - *nlines = VIPS_MAX( *nlines, vips__fatstrip_height * nthr * 2 ); - *nlines = VIPS_MAX( *nlines, vips__thinstrip_height * nthr * 2 ); - *nlines = ROUND_UP( *nlines, *tile_height ); + *n_lines = VIPS_MAX( *n_lines, vips__fatstrip_height * nthr * 2 ); + *n_lines = VIPS_MAX( *n_lines, vips__thinstrip_height * nthr * 2 ); + *n_lines = ROUND_UP( *n_lines, *tile_height ); /* We make this assumption in several places. */ - g_assert( *nlines % *tile_height == 0 ); + g_assert( *n_lines % *tile_height == 0 ); VIPS_DEBUG_MSG( "vips_get_tile_size: %d by %d patches, " "groups of %d scanlines\n", - *tile_width, *tile_height, *nlines ); + *tile_width, *tile_height, *n_lines ); } From 32a8fe117e55289a775234e728bc2eb17b149b76 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 25 Jul 2014 18:06:52 +0100 Subject: [PATCH 4/4] start working on --disable-deprecated need to move im_conv() etc to classes to finish this --- ChangeLog | 3 + TODO | 4 + configure.ac | 28 +++++-- libvips/Makefile.am | 29 ++++--- libvips/arithmetic/arithmetic.c | 2 +- libvips/arithmetic/avg.c | 3 +- libvips/arithmetic/complex.c | 2 +- libvips/arithmetic/math.c | 12 +-- libvips/arithmetic/max.c | 3 +- libvips/arithmetic/min.c | 3 +- libvips/arithmetic/round.c | 4 +- libvips/arithmetic/unaryconst.c | 2 +- libvips/arithmetic/unaryconst.h | 2 +- libvips/colour/dE00.c | 12 +-- libvips/conversion/bandary.c | 2 +- libvips/conversion/bandmean.c | 3 +- libvips/conversion/conversion.c | 97 ---------------------- libvips/conversion/embed.c | 2 +- libvips/conversion/grid.c | 2 +- libvips/conversion/insert.c | 2 +- libvips/conversion/msb.c | 2 +- libvips/conversion/recomb.c | 2 +- libvips/conversion/rot.c | 14 ++-- libvips/convolution/im_conv_f.c | 2 +- libvips/deprecated/im_linreg.c | 2 +- libvips/deprecated/im_maxpos_avg.c | 4 +- libvips/deprecated/im_resize_linear.c | 2 +- libvips/deprecated/rename.c | 2 +- libvips/deprecated/vips7compat.c | 101 ++++++++++++++++++++++- libvips/foreign/analyze2vips.c | 2 +- libvips/foreign/fits.c | 2 +- libvips/foreign/ppm.c | 2 +- libvips/foreign/radiance.c | 2 +- libvips/foreign/rawsave.c | 4 +- libvips/foreign/vips2jpeg.c | 2 +- libvips/foreign/vips2tiff.c | 2 +- libvips/foreign/vipspng.c | 2 +- libvips/freqfilt/freqmult.c | 2 +- libvips/freqfilt/fwfft.c | 2 +- libvips/histogram/hist_cum.c | 3 +- libvips/include/vips/dispatch.h | 2 + libvips/include/vips/internal.h | 113 ++------------------------ libvips/include/vips/version.h.in | 1 + libvips/include/vips/vips.h | 17 ++-- libvips/include/vips/vips7compat.h | 109 ++++++++++++++++++++++++- libvips/mosaicing/im_lrmerge.c | 4 +- libvips/mosaicing/im_tbmerge.c | 4 +- libvips/resample/lbb.cpp | 3 +- libvips/resample/nohalo.cpp | 3 +- libvips/resample/shrink.c | 2 +- libvips/resample/transform.c | 37 +++++---- libvips/resample/vsqbs.cpp | 5 +- tools/Makefile.am | 4 +- tools/{vips-7.40 => vips-7.41} | 0 54 files changed, 361 insertions(+), 316 deletions(-) rename tools/{vips-7.40 => vips-7.41} (100%) diff --git a/ChangeLog b/ChangeLog index 507eca71..b252f6f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +25/7/14 started 7.41.0 +- start working on --disable-deprecated + 25/7/14 started 7.40.5 - fix a race in im_maxpos_avg() - limit n_thr on tiny images diff --git a/TODO b/TODO index 3c84c9aa..8cf2da28 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,7 @@ +- rewrite im_conv() etc. as vips_conv() + + finally finish --disable-deprecated option + - check and fix up docs diff --git a/configure.ac b/configure.ac index e9327fff..cc26ec91 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [7.40.5], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [7.41.0], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -17,8 +17,8 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [7]) -m4_define([vips_minor_version], [40]) -m4_define([vips_micro_version], [5]) +m4_define([vips_minor_version], [41]) +m4_define([vips_micro_version], [0]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -124,9 +124,26 @@ else fi fi +# option to disable deprecated code, shaves a bit off the library size +AC_ARG_ENABLE(deprecated, + AS_HELP_STRING([--enable-deprecated], [build deprecated components (default: yes)])) + +VIPS_ENABLE_DEPRECATED=0 +if test x"$enable_deprecated" != x"no"; then + VIPS_ENABLE_DEPRECATED=1 + enable_deprecated=yes + AM_CONDITIONAL(ENABLE_DEPRECATED, true) +else + AM_CONDITIONAL(ENABLE_DEPRECATED, false) +fi + +# this gets pasted into version.h as a #define +AC_SUBST(VIPS_ENABLE_DEPRECATED) + # we are a C library with some optional C++ components inside it -# on most platforms, we just include -lstdc++ in the link line for programs -# using vips, but not all + +# on most platforms, but not all, we just include -lstdc++ in the link line +# for programs # we ought to write a proper configure test for this :( @@ -806,6 +823,7 @@ native win32: $vips_os_win32 native OS X: $vips_os_darwin open files in binary mode: $vips_binary_open enable debug: $enable_debug +build deprecated components: $enable_deprecated build C++ components: $enable_cxx build docs with gtkdoc: $enable_gtk_doc install docs: $enable_docs diff --git a/libvips/Makefile.am b/libvips/Makefile.am index 7640d325..8ccbf813 100644 --- a/libvips/Makefile.am +++ b/libvips/Makefile.am @@ -1,12 +1,21 @@ +OPTIONAL_COMPILE_DIR = +OPTIONAL_DIST_DIR = +OPTIONAL_LIB = + # only build in the cimg dir if C++ is enabled if ENABLE_CXX -C_COMPILE_DIR = cimg -C_DIST_DIR = -C_LIB = cimg/libcimg.la +OPTIONAL_COMPILE_DIR += cimg +OPTIONAL_LIB += cimg/libcimg.la else -C_COMPILE_DIR = -C_DIST_DIR = cimg -C_LIB = +OPTIONAL_DIST_DIR += cimg +endif + +# same for deprecated +if ENABLE_DEPRECATED +OPTIONAL_COMPILE_DIR += deprecated +OPTIONAL_LIB += deprecated/libdeprecated.la +else +OPTIONAL_DIST_DIR += deprecated endif SUBDIRS = \ @@ -16,9 +25,8 @@ SUBDIRS = \ resample \ colour \ conversion \ - deprecated \ convolution \ - $(C_COMPILE_DIR) \ + $(OPTIONAL_COMPILE_DIR) \ freqfilt \ histogram \ draw \ @@ -49,8 +57,7 @@ libvips_la_LIBADD = \ colour/libcolour.la \ conversion/libconversion.la \ convolution/libconvolution.la \ - deprecated/libdeprecated.la \ - $(C_LIB) \ + $(OPTIONAL_LIB) \ foreign/libforeign.la \ freqfilt/libfreqfilt.la \ histogram/libhistogram.la \ @@ -71,7 +78,7 @@ libvips_la_LDFLAGS = \ -version-info @LIBRARY_CURRENT@:@LIBRARY_REVISION@:@LIBRARY_AGE@ EXTRA_DIST = \ - $(C_DIST_DIR) + $(OPTIONAL_DIST_DIR) CLEANFILES = diff --git a/libvips/arithmetic/arithmetic.c b/libvips/arithmetic/arithmetic.c index 550d464b..dec9c77c 100644 --- a/libvips/arithmetic/arithmetic.c +++ b/libvips/arithmetic/arithmetic.c @@ -464,7 +464,7 @@ vips_arithmetic_gen( VipsRegion *or, VipsRegion **ir = (VipsRegion **) seq; VipsArithmetic *arithmetic = VIPS_ARITHMETIC( b ); VipsArithmeticClass *class = VIPS_ARITHMETIC_GET_CLASS( arithmetic ); - Rect *r = &or->valid; + VipsRect *r = &or->valid; VipsPel *p[MAX_INPUT_IMAGES], *q; int i, y; diff --git a/libvips/arithmetic/avg.c b/libvips/arithmetic/avg.c index 70765942..ca49214f 100644 --- a/libvips/arithmetic/avg.c +++ b/libvips/arithmetic/avg.c @@ -106,7 +106,8 @@ vips_avg_build( VipsObject *object ) vips_image_get_height( statistic->in ) * vips_image_get_bands( statistic->in ); average = avg->sum / vals; - if( vips_bandfmt_iscomplex( vips_image_get_format( statistic->in ) ) ) + if( vips_band_format_iscomplex( + vips_image_get_format( statistic->in ) ) ) average = sqrt( average ); g_object_set( object, "out", average, NULL ); diff --git a/libvips/arithmetic/complex.c b/libvips/arithmetic/complex.c index e3a4fd67..2cfa6428 100644 --- a/libvips/arithmetic/complex.c +++ b/libvips/arithmetic/complex.c @@ -135,7 +135,7 @@ G_DEFINE_TYPE( VipsComplex, vips_complex, VIPS_TYPE_UNARY ); double am, ph; \ \ am = sqrt( re * re + im * im ); \ - ph = im_col_ab2h( re, im ); \ + ph = vips_col_ab2h( re, im ); \ \ Q[0] = am; \ Q[1] = ph; \ diff --git a/libvips/arithmetic/math.c b/libvips/arithmetic/math.c index aad84c96..d945afe4 100644 --- a/libvips/arithmetic/math.c +++ b/libvips/arithmetic/math.c @@ -129,12 +129,12 @@ vips_math_build( VipsObject *object ) /* sin/cos/tan in degrees. */ -#define DSIN( X ) (sin( IM_RAD( X ) )) -#define DCOS( X ) (cos( IM_RAD( X ) )) -#define DTAN( X ) (tan( IM_RAD( X ) )) -#define ADSIN( X ) (IM_DEG( asin( X ) )) -#define ADCOS( X ) (IM_DEG( acos( X ) )) -#define ADTAN( X ) (IM_DEG( atan( X ) )) +#define DSIN( X ) (sin( VIPS_RAD( X ) )) +#define DCOS( X ) (cos( VIPS_RAD( X ) )) +#define DTAN( X ) (tan( VIPS_RAD( X ) )) +#define ADSIN( X ) (VIPS_DEG( asin( X ) )) +#define ADCOS( X ) (VIPS_DEG( acos( X ) )) +#define ADTAN( X ) (VIPS_DEG( atan( X ) )) /* exp10() is a gnu extension, use pow(). */ diff --git a/libvips/arithmetic/max.c b/libvips/arithmetic/max.c index cf996302..c53fc3df 100644 --- a/libvips/arithmetic/max.c +++ b/libvips/arithmetic/max.c @@ -197,7 +197,8 @@ vips_max_build( VipsObject *object ) /* For speed we accumulate max ** 2 for complex. */ - if( vips_bandfmt_iscomplex( vips_image_get_format( statistic->in ) ) ) { + if( vips_band_format_iscomplex( + vips_image_get_format( statistic->in ) ) ) { int i; for( i = 0; i < values->n; i++ ) diff --git a/libvips/arithmetic/min.c b/libvips/arithmetic/min.c index 5daad851..8772f3ed 100644 --- a/libvips/arithmetic/min.c +++ b/libvips/arithmetic/min.c @@ -199,7 +199,8 @@ vips_min_build( VipsObject *object ) /* For speed we accumulate min ** 2 for complex. */ - if( vips_bandfmt_iscomplex( vips_image_get_format( statistic->in ) ) ) { + if( vips_band_format_iscomplex( + vips_image_get_format( statistic->in ) ) ) { int i; for( i = 0; i < values->n; i++ ) diff --git a/libvips/arithmetic/round.c b/libvips/arithmetic/round.c index e12a2d69..4e97aaba 100644 --- a/libvips/arithmetic/round.c +++ b/libvips/arithmetic/round.c @@ -75,7 +75,7 @@ vips_round_build( VipsObject *object ) * is. */ if( unary->in && - vips_bandfmt_isint( unary->in->BandFmt ) ) + vips_band_format_isint( unary->in->BandFmt ) ) return( vips_unary_copy( unary ) ); if( VIPS_OBJECT_CLASS( vips_round_parent_class )->build( object ) ) @@ -115,7 +115,7 @@ vips_round_buffer( VipsArithmetic *arithmetic, /* Complex just doubles the size. */ const int sz = width * im->Bands * - (vips_bandfmt_iscomplex( im->BandFmt ) ? 2 : 1); + (vips_band_format_iscomplex( im->BandFmt ) ? 2 : 1); int x; diff --git a/libvips/arithmetic/unaryconst.c b/libvips/arithmetic/unaryconst.c index 8f12faf8..9bc7f0f5 100644 --- a/libvips/arithmetic/unaryconst.c +++ b/libvips/arithmetic/unaryconst.c @@ -87,7 +87,7 @@ G_DEFINE_ABSTRACT_TYPE( VipsUnaryConst, vips_unary_const, VIPS_TYPE_UNARY ); */ static VipsPel * make_pixel( VipsObject *obj, - int m, VipsBandFmt fmt, int n, double * restrict p ) + int m, VipsBandFormat fmt, int n, double * restrict p ) { VipsPel *q; int i; diff --git a/libvips/arithmetic/unaryconst.h b/libvips/arithmetic/unaryconst.h index 36094b61..2d204426 100644 --- a/libvips/arithmetic/unaryconst.h +++ b/libvips/arithmetic/unaryconst.h @@ -62,7 +62,7 @@ typedef struct _VipsUnaryConst { /* The format the constant should be cast to. Subclasses set this * ready for unaryconst's build method. */ - VipsBandFmt const_format; + VipsBandFormat const_format; /* Our constant expanded to match arith->ready in size and * const_format in type. diff --git a/libvips/colour/dE00.c b/libvips/colour/dE00.c index 52ff3374..d9ac152c 100644 --- a/libvips/colour/dE00.c +++ b/libvips/colour/dE00.c @@ -145,12 +145,12 @@ vips_col_dE00( float L1, float a1, float b1, /* RT, T. */ - double RT = -sin( IM_RAD( 2 * dtheta ) ) * RC; + double RT = -sin( VIPS_RAD( 2 * dtheta ) ) * RC; double T = 1 - - 0.17 * cos( IM_RAD( hdb - 30 ) ) + - 0.24 * cos( IM_RAD( 2 * hdb ) ) + - 0.32 * cos( IM_RAD( 3 * hdb + 6 ) ) - - 0.20 * cos( IM_RAD( 4 * hdb - 63 ) ); + 0.17 * cos( VIPS_RAD( hdb - 30 ) ) + + 0.24 * cos( VIPS_RAD( 2 * hdb ) ) + + 0.32 * cos( VIPS_RAD( 3 * hdb + 6 ) ) - + 0.20 * cos( VIPS_RAD( 4 * hdb - 63 ) ); /* SL, SC, SH */ @@ -169,7 +169,7 @@ vips_col_dE00( float L1, float a1, float b1, */ double dLd = L1d - L2d; double dCd = C1d - C2d; - double dHd = 2 * sqrt( C1d * C2d ) * sin( IM_RAD( dhd / 2 ) ); + double dHd = 2 * sqrt( C1d * C2d ) * sin( VIPS_RAD( dhd / 2 ) ); /* Parametric factors for viewing parameters. */ diff --git a/libvips/conversion/bandary.c b/libvips/conversion/bandary.c index 33791919..66b9ef5f 100644 --- a/libvips/conversion/bandary.c +++ b/libvips/conversion/bandary.c @@ -87,7 +87,7 @@ vips_bandary_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) VipsRegion **ir = (VipsRegion **) seq; VipsBandary *bandary = (VipsBandary *) b; VipsBandaryClass *class = VIPS_BANDARY_GET_CLASS( bandary ); - Rect *r = &or->valid; + VipsRect *r = &or->valid; VipsPel *p[MAX_INPUT_IMAGES], *q; int y, i; diff --git a/libvips/conversion/bandmean.c b/libvips/conversion/bandmean.c index f1b61f44..4f00f0f5 100644 --- a/libvips/conversion/bandmean.c +++ b/libvips/conversion/bandmean.c @@ -125,7 +125,8 @@ vips_bandmean_buffer( VipsBandary *bandary, { VipsImage *im = bandary->ready[0]; const int bands = im->Bands; - const int sz = width * (vips_bandfmt_iscomplex( im->BandFmt ) ? 2 : 1); + const int sz = width * + (vips_band_format_iscomplex( im->BandFmt ) ? 2 : 1); int i, j; diff --git a/libvips/conversion/conversion.c b/libvips/conversion/conversion.c index 980cfe51..a4623ae7 100644 --- a/libvips/conversion/conversion.c +++ b/libvips/conversion/conversion.c @@ -272,100 +272,3 @@ vips_conversion_operation_init( void ) vips_falsecolour_get_type(); vips_gamma_get_type(); } - -/* The common part of most binary conversion - * operators. We: - * - * - check in and out - * - cast in1 and in2 up to a common format - * - equalise bands - * - make an input array - * - return the matched images in vec[0] and vec[1] - * - * A left-over, remove soon. - */ -IMAGE ** -im__insert_base( const char *domain, - IMAGE *in1, IMAGE *in2, IMAGE *out ) -{ - IMAGE *t[4]; - IMAGE **vec; - - if( im_piocheck( in1, out ) || - im_pincheck( in2 ) || - im_check_bands_1orn( domain, in1, in2 ) || - im_check_coding_known( domain, in1 ) || - im_check_coding_same( domain, in1, in2 ) ) - return( NULL ); - - /* Cast our input images up to a common format and bands. - */ - if( im_open_local_array( out, t, 4, domain, "p" ) || - im__formatalike( in1, in2, t[0], t[1] ) || - im__bandalike( domain, t[0], t[1], t[2], t[3] ) || - !(vec = im_allocate_input_array( out, t[2], t[3], NULL )) ) - return( NULL ); - - /* Generate the output. - */ - if( im_cp_descv( out, vec[0], vec[1], NULL ) || - im_demand_hint_array( out, IM_SMALLTILE, vec ) ) - return( NULL ); - - return( vec ); -} - -/** - * im_insertset: - * @main: big image - * @sub: small image - * @out: output image - * @n: number of positions - * @x: left positions of @sub - * @y: top positions of @sub - * - * Insert @sub repeatedly into @main at the positions listed in the arrays @x, - * @y of length @n. @out is the same - * size as @main. @sub is clipped against the edges of @main. - * - * This operation is fast for large @n, but will use a memory buffer the size - * of @out. It's useful for things like making scatter plots. - * - * If the number of bands differs, one of the images - * must have one band. In this case, an n-band image is formed from the - * one-band image by joining n copies of the one-band image together, and then - * the two n-band images are operated upon. - * - * The two input images are cast up to the smallest common type (see table - * Smallest common format in - * arithmetic). - * - * See also: im_insert(), im_lrjoin(). - * - * Returns: 0 on success, -1 on error - */ -int -im_insertset( IMAGE *main, IMAGE *sub, IMAGE *out, int n, int *x, int *y ) -{ - IMAGE **vec; - IMAGE *t; - int i; - - if( !(vec = im__insert_base( "im_insert", main, sub, out )) ) - return( -1 ); - - /* Copy to a memory image, zap that, then copy to out. - */ - if( !(t = im_open_local( out, "im_insertset", "t" )) || - im_copy( vec[0], t ) ) - return( -1 ); - - for( i = 0; i < n; i++ ) - if( im_insertplace( t, vec[1], x[i], y[i] ) ) - return( -1 ); - - if( im_copy( t, out ) ) - return( -1 ); - - return( 0 ); -} diff --git a/libvips/conversion/embed.c b/libvips/conversion/embed.c index 8e31040f..8a5e9a8b 100644 --- a/libvips/conversion/embed.c +++ b/libvips/conversion/embed.c @@ -224,7 +224,7 @@ vips_embed_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) VipsEmbed *embed = (VipsEmbed *) b; VipsRect *r = &or->valid; - Rect ovl; + VipsRect ovl; int i; VipsPel *p; int plsk; diff --git a/libvips/conversion/grid.c b/libvips/conversion/grid.c index be39dfd5..fd0a2c95 100644 --- a/libvips/conversion/grid.c +++ b/libvips/conversion/grid.c @@ -93,7 +93,7 @@ vips_grid_gen( VipsRegion *or, void *vseq, void *a, void *b, /* If the request fits inside a single tile, we can just pointer-copy. */ if( vips_rect_includesrect( &tile, r ) ) { - Rect irect; + VipsRect irect; /* Translate request to input space. */ diff --git a/libvips/conversion/insert.c b/libvips/conversion/insert.c index d9bbb9bb..c63dec5b 100644 --- a/libvips/conversion/insert.c +++ b/libvips/conversion/insert.c @@ -169,7 +169,7 @@ vips_insert_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) VipsRect *r = &or->valid; VipsInsert *insert = (VipsInsert *) b; - Rect ovl; + VipsRect ovl; /* Does the rect we have been asked for fall entirely inside the * sub-image? diff --git a/libvips/conversion/msb.c b/libvips/conversion/msb.c index 9a526e6f..33f931c8 100644 --- a/libvips/conversion/msb.c +++ b/libvips/conversion/msb.c @@ -190,7 +190,7 @@ vips_msb_build( VipsObject *object ) msb->band > 0 ) msb->sign = TRUE; if( msb->in->Coding == VIPS_CODING_NONE && - !vips_bandfmt_isuint( msb->in->BandFmt ) ) + !vips_band_format_isuint( msb->in->BandFmt ) ) msb->sign = TRUE; if( msb->band == -1 && diff --git a/libvips/conversion/recomb.c b/libvips/conversion/recomb.c index 7041de01..58396467 100644 --- a/libvips/conversion/recomb.c +++ b/libvips/conversion/recomb.c @@ -176,7 +176,7 @@ vips_recomb_build( VipsObject *object ) return( -1 ); conversion->out->Bands = recomb->m->Ysize; - if( vips_bandfmt_isint( in->BandFmt ) ) + if( vips_band_format_isint( in->BandFmt ) ) conversion->out->BandFmt = VIPS_FORMAT_FLOAT; if( vips_image_generate( conversion->out, diff --git a/libvips/conversion/rot.c b/libvips/conversion/rot.c index 8c9c9e73..49848c50 100644 --- a/libvips/conversion/rot.c +++ b/libvips/conversion/rot.c @@ -102,9 +102,9 @@ vips_rot90_gen( VipsRegion *or, void *seq, void *a, void *b, */ VipsRect *r = &or->valid; int le = r->left; - int ri = IM_RECT_RIGHT(r); + int ri = VIPS_RECT_RIGHT(r); int to = r->top; - int bo = IM_RECT_BOTTOM(r); + int bo = VIPS_RECT_BOTTOM(r); int x, y, i; @@ -164,9 +164,9 @@ vips_rot180_gen( VipsRegion *or, void *seq, void *a, void *b, */ VipsRect *r = &or->valid; int le = r->left; - int ri = IM_RECT_RIGHT(r); + int ri = VIPS_RECT_RIGHT(r); int to = r->top; - int bo = IM_RECT_BOTTOM(r); + int bo = VIPS_RECT_BOTTOM(r); int x, y; @@ -176,7 +176,7 @@ vips_rot180_gen( VipsRegion *or, void *seq, void *a, void *b, /* Find the area of the input image we need. */ - Rect need; + VipsRect need; need.left = in->Xsize - ri; need.top = in->Ysize - bo; @@ -225,9 +225,9 @@ vips_rot270_gen( VipsRegion *or, void *seq, void *a, void *b, */ VipsRect *r = &or->valid; int le = r->left; - int ri = IM_RECT_RIGHT(r); + int ri = VIPS_RECT_RIGHT(r); int to = r->top; - int bo = IM_RECT_BOTTOM(r); + int bo = VIPS_RECT_BOTTOM(r); int x, y, i; diff --git a/libvips/convolution/im_conv_f.c b/libvips/convolution/im_conv_f.c index ecee8d03..d23872b6 100644 --- a/libvips/convolution/im_conv_f.c +++ b/libvips/convolution/im_conv_f.c @@ -245,7 +245,7 @@ conv_gen( REGION *or, void *vseq, void *a, void *b ) int to = r->top; int bo = IM_RECT_BOTTOM(r); int sz = IM_REGION_N_ELEMENTS( or ) * - (vips_bandfmt_iscomplex( in->BandFmt ) ? 2 : 1); + (vips_band_format_iscomplex( in->BandFmt ) ? 2 : 1); int x, y, z, i; diff --git a/libvips/deprecated/im_linreg.c b/libvips/deprecated/im_linreg.c index c2d93679..f773d33f 100644 --- a/libvips/deprecated/im_linreg.c +++ b/libvips/deprecated/im_linreg.c @@ -183,7 +183,7 @@ int im_linreg( IMAGE **ins, IMAGE *out, double *xs ){ } } else { - if( vips_bandfmt_iscomplex( ins[ 0 ]->BandFmt ) ){ + if( vips_band_format_iscomplex( ins[ 0 ]->BandFmt ) ){ im_error( FUNCTION_NAME, "image has non-scalar band format" ); return( -1 ); } diff --git a/libvips/deprecated/im_maxpos_avg.c b/libvips/deprecated/im_maxpos_avg.c index 0d7f0417..36ae6580 100644 --- a/libvips/deprecated/im_maxpos_avg.c +++ b/libvips/deprecated/im_maxpos_avg.c @@ -259,7 +259,7 @@ im_maxpos_avg( IMAGE *in, double *xpos, double *ypos, double *out ) /* We use square mod for scanning, for speed. */ - if( vips_bandfmt_iscomplex( in->BandFmt ) ) + if( vips_band_format_iscomplex( in->BandFmt ) ) global_maxposavg->max *= global_maxposavg->max; if( vips_sink( in, maxposavg_start, maxposavg_scan, maxposavg_stop, @@ -268,7 +268,7 @@ im_maxpos_avg( IMAGE *in, double *xpos, double *ypos, double *out ) /* Back to modulus. */ - if( vips_bandfmt_iscomplex( in->BandFmt ) ) + if( vips_band_format_iscomplex( in->BandFmt ) ) global_maxposavg->max = sqrt( global_maxposavg->max ); if( xpos ) diff --git a/libvips/deprecated/im_resize_linear.c b/libvips/deprecated/im_resize_linear.c index bb901bbc..75920bc7 100644 --- a/libvips/deprecated/im_resize_linear.c +++ b/libvips/deprecated/im_resize_linear.c @@ -118,7 +118,7 @@ im_resize_linear( IMAGE *in, IMAGE *out, int X, int Y ) if( im_iocheck( in, out ) ) return( -1 ); - if( vips_bandfmt_iscomplex( in->BandFmt ) ) { + if( vips_band_format_iscomplex( in->BandFmt ) ) { im_error( "im_lowpass", "%s", _( "non-complex input only" ) ); return( -1 ); } diff --git a/libvips/deprecated/rename.c b/libvips/deprecated/rename.c index 5b47cecd..2d39f8a3 100644 --- a/libvips/deprecated/rename.c +++ b/libvips/deprecated/rename.c @@ -277,7 +277,7 @@ im_isfloat( IMAGE *im ) gboolean im_iscomplex( IMAGE *im ) { - return( vips_bandfmt_iscomplex( im->BandFmt ) ); + return( vips_band_format_iscomplex( im->BandFmt ) ); } gboolean diff --git a/libvips/deprecated/vips7compat.c b/libvips/deprecated/vips7compat.c index 673602a8..5090548c 100644 --- a/libvips/deprecated/vips7compat.c +++ b/libvips/deprecated/vips7compat.c @@ -769,8 +769,8 @@ static int bandfmt_largest[6][6] = { static VipsBandFmt im__format_common( VipsBandFmt in1, VipsBandFmt in2 ) { - if( vips_bandfmt_iscomplex( in1 ) || - vips_bandfmt_iscomplex( in2 ) ) { + if( vips_band_format_iscomplex( in1 ) || + vips_band_format_iscomplex( in2 ) ) { /* What kind of complex? */ if( in1 == IM_BANDFMT_DPCOMPLEX || in2 == IM_BANDFMT_DPCOMPLEX ) @@ -5255,3 +5255,100 @@ im_tbmerge1( IMAGE *ref, IMAGE *sec, IMAGE *out, return( 0 ); } + +/* The common part of most binary conversion + * operators. We: + * + * - check in and out + * - cast in1 and in2 up to a common format + * - equalise bands + * - make an input array + * - return the matched images in vec[0] and vec[1] + * + * A left-over, remove soon. + */ +IMAGE ** +im__insert_base( const char *domain, + IMAGE *in1, IMAGE *in2, IMAGE *out ) +{ + IMAGE *t[4]; + IMAGE **vec; + + if( im_piocheck( in1, out ) || + im_pincheck( in2 ) || + im_check_bands_1orn( domain, in1, in2 ) || + im_check_coding_known( domain, in1 ) || + im_check_coding_same( domain, in1, in2 ) ) + return( NULL ); + + /* Cast our input images up to a common format and bands. + */ + if( im_open_local_array( out, t, 4, domain, "p" ) || + im__formatalike( in1, in2, t[0], t[1] ) || + im__bandalike( domain, t[0], t[1], t[2], t[3] ) || + !(vec = im_allocate_input_array( out, t[2], t[3], NULL )) ) + return( NULL ); + + /* Generate the output. + */ + if( im_cp_descv( out, vec[0], vec[1], NULL ) || + im_demand_hint_array( out, IM_SMALLTILE, vec ) ) + return( NULL ); + + return( vec ); +} + +/** + * im_insertset: + * @main: big image + * @sub: small image + * @out: output image + * @n: number of positions + * @x: left positions of @sub + * @y: top positions of @sub + * + * Insert @sub repeatedly into @main at the positions listed in the arrays @x, + * @y of length @n. @out is the same + * size as @main. @sub is clipped against the edges of @main. + * + * This operation is fast for large @n, but will use a memory buffer the size + * of @out. It's useful for things like making scatter plots. + * + * If the number of bands differs, one of the images + * must have one band. In this case, an n-band image is formed from the + * one-band image by joining n copies of the one-band image together, and then + * the two n-band images are operated upon. + * + * The two input images are cast up to the smallest common type (see table + * Smallest common format in + * arithmetic). + * + * See also: im_insert(), im_lrjoin(). + * + * Returns: 0 on success, -1 on error + */ +int +im_insertset( IMAGE *main, IMAGE *sub, IMAGE *out, int n, int *x, int *y ) +{ + IMAGE **vec; + IMAGE *t; + int i; + + if( !(vec = im__insert_base( "im_insert", main, sub, out )) ) + return( -1 ); + + /* Copy to a memory image, zap that, then copy to out. + */ + if( !(t = im_open_local( out, "im_insertset", "t" )) || + im_copy( vec[0], t ) ) + return( -1 ); + + for( i = 0; i < n; i++ ) + if( im_insertplace( t, vec[1], x[i], y[i] ) ) + return( -1 ); + + if( im_copy( t, out ) ) + return( -1 ); + + return( 0 ); +} diff --git a/libvips/foreign/analyze2vips.c b/libvips/foreign/analyze2vips.c index 6413f79f..f73f3372 100644 --- a/libvips/foreign/analyze2vips.c +++ b/libvips/foreign/analyze2vips.c @@ -437,7 +437,7 @@ get_vips_properties( struct dsr *d, } static void -attach_meta( IMAGE *out, struct dsr *d ) +attach_meta( VipsImage *out, struct dsr *d ) { int i; diff --git a/libvips/foreign/fits.c b/libvips/foreign/fits.c index 4a0a56e7..068a27d4 100644 --- a/libvips/foreign/fits.c +++ b/libvips/foreign/fits.c @@ -351,7 +351,7 @@ fits2vips_generate( VipsRegion *out, void *seq, void *a, void *b, gboolean *stop ) { VipsFits *fits = (VipsFits *) a; - Rect *r = &out->valid; + VipsRect *r = &out->valid; VipsPel *q; int z; diff --git a/libvips/foreign/ppm.c b/libvips/foreign/ppm.c index 16ef125a..8b4326b0 100644 --- a/libvips/foreign/ppm.c +++ b/libvips/foreign/ppm.c @@ -622,7 +622,7 @@ write_ppm_line_binary( VipsImage *in, FILE *fp, VipsPel *p ) } static int -write_ppm_block( REGION *region, Rect *area, void *a ) +write_ppm_block( VipsRegion *region, VipsRect *area, void *a ) { Write *write = (Write *) a; int i; diff --git a/libvips/foreign/radiance.c b/libvips/foreign/radiance.c index d52e0ab8..0c0a9a7a 100644 --- a/libvips/foreign/radiance.c +++ b/libvips/foreign/radiance.c @@ -1227,7 +1227,7 @@ vips2rad_put_header( Write *write ) } static int -vips2rad_put_data_block( VipsRegion *region, Rect *area, void *a ) +vips2rad_put_data_block( VipsRegion *region, VipsRect *area, void *a ) { Write *write = (Write *) a; int i; diff --git a/libvips/foreign/rawsave.c b/libvips/foreign/rawsave.c index a5250f81..92aeb83f 100644 --- a/libvips/foreign/rawsave.c +++ b/libvips/foreign/rawsave.c @@ -88,7 +88,7 @@ vips_foreign_save_raw_dispose( GObject *gobject ) } static int -vips_foreign_save_raw_write( VipsRegion *region, Rect *area, void *a ) +vips_foreign_save_raw_write( VipsRegion *region, VipsRect *area, void *a ) { VipsForeignSave *save = (VipsForeignSave *) a; VipsForeignSaveRaw *raw = (VipsForeignSaveRaw *) a; @@ -195,7 +195,7 @@ G_DEFINE_TYPE( VipsForeignSaveRawFd, vips_foreign_save_raw_fd, VIPS_TYPE_FOREIGN_SAVE ); static int -vips_foreign_save_raw_fd_write( VipsRegion *region, Rect *area, void *a ) +vips_foreign_save_raw_fd_write( VipsRegion *region, VipsRect *area, void *a ) { VipsForeignSave *save = (VipsForeignSave *) a; VipsForeignSaveRawFd *fd = (VipsForeignSaveRawFd *) a; diff --git a/libvips/foreign/vips2jpeg.c b/libvips/foreign/vips2jpeg.c index 06e5a121..5bf14b42 100644 --- a/libvips/foreign/vips2jpeg.c +++ b/libvips/foreign/vips2jpeg.c @@ -825,7 +825,7 @@ write_profile_meta( Write *write ) } static int -write_jpeg_block( REGION *region, Rect *area, void *a ) +write_jpeg_block( VipsRegion *region, VipsRect *area, void *a ) { Write *write = (Write *) a; int i; diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 0294f9ba..0fba3dd6 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -1343,7 +1343,7 @@ make_tiff_write( VipsImage *im, const char *filename, */ if( tw->pyramid ) { if( im->Coding == VIPS_CODING_NONE && - vips_bandfmt_iscomplex( im->BandFmt ) ) { + vips_band_format_iscomplex( im->BandFmt ) ) { vips_error( "vips2tiff", "%s", _( "can only pyramid LABQ and " "non-complex images" ) ); diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index f563b03e..4145131a 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -729,7 +729,7 @@ write_new( VipsImage *in ) } static int -write_png_block( VipsRegion *region, Rect *area, void *a ) +write_png_block( VipsRegion *region, VipsRect *area, void *a ) { Write *write = (Write *) a; diff --git a/libvips/freqfilt/freqmult.c b/libvips/freqfilt/freqmult.c index 20b0682f..9e35d882 100644 --- a/libvips/freqfilt/freqmult.c +++ b/libvips/freqfilt/freqmult.c @@ -80,7 +80,7 @@ vips_freqmult_build( VipsObject *object ) in = freqfilt->in; - if( vips_bandfmt_iscomplex( in->BandFmt ) ) { + if( vips_band_format_iscomplex( in->BandFmt ) ) { if( vips_multiply( in, freqmult->mask, &t[0], NULL ) || vips_invfft( t[0], &t[1], "real", TRUE, NULL ) ) return( -1 ); diff --git a/libvips/freqfilt/fwfft.c b/libvips/freqfilt/fwfft.c index cddcc3ca..4d346358 100644 --- a/libvips/freqfilt/fwfft.c +++ b/libvips/freqfilt/fwfft.c @@ -309,7 +309,7 @@ vips_fwfft_build( VipsObject *object ) return( -1 ); in = t[0]; - if( vips_bandfmt_iscomplex( in->BandFmt ) ) { + if( vips_band_format_iscomplex( in->BandFmt ) ) { if( vips__fftproc( VIPS_OBJECT( fwfft ), in, &t[1], cfwfft1 ) ) return( -1 ); diff --git a/libvips/histogram/hist_cum.c b/libvips/histogram/hist_cum.c index 7a3836bf..a81907ab 100644 --- a/libvips/histogram/hist_cum.c +++ b/libvips/histogram/hist_cum.c @@ -87,7 +87,8 @@ vips_hist_cum_process( VipsHistogram *histogram, VipsPel *out, VipsPel **in, int width ) { const int bands = vips_image_get_bands( histogram->ready[0] ); - const int nb = vips_bandfmt_iscomplex( histogram->ready[0]->BandFmt ) ? + const int nb = + vips_band_format_iscomplex( histogram->ready[0]->BandFmt ) ? bands * 2 : bands; int mx = width * nb; diff --git a/libvips/include/vips/dispatch.h b/libvips/include/vips/dispatch.h index cb6bd96a..457c2cd4 100644 --- a/libvips/include/vips/dispatch.h +++ b/libvips/include/vips/dispatch.h @@ -292,6 +292,8 @@ int im_allocate_vargv( im_function *fn, im_object *vargv ); */ int im_run_command( char *name, int argc, char **argv ); +int vips__input_interpolate_init( im_object *obj, char *str ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index e6139a41..23451125 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -105,7 +105,8 @@ void vips__cache_init( void ); void vips__type_leak( void ); typedef int (*im__fftproc_fn)( VipsImage *, VipsImage *, VipsImage * ); -int im__fftproc( IMAGE *dummy, IMAGE *in, IMAGE *out, im__fftproc_fn fn ); +int im__fftproc( VipsImage *dummy, + VipsImage *in, VipsImage *out, im__fftproc_fn fn ); /* iofuncs */ @@ -164,109 +165,6 @@ int vips__sizealike( VipsImage *in1, VipsImage *in2, int vips__bandalike( const char *domain, VipsImage *in1, VipsImage *in2, VipsImage **out1, VipsImage **out2 ); - -void im__format_init( void ); - -void im__tiff_register( void ); -void im__jpeg_register( void ); -void im__png_register( void ); -void im__csv_register( void ); -void im__ppm_register( void ); -void im__analyze_register( void ); -void im__exr_register( void ); -void im__magick_register( void ); - -int im__bandup( const char *domain, VipsImage *in, VipsImage *out, int n ); -int im__bandalike_vec( const char *domain, VipsImage **in, VipsImage **out, int n ); -int im__bandalike( const char *domain, - VipsImage *in1, VipsImage *in2, VipsImage *out1, VipsImage *out2 ); -int im__formatalike_vec( VipsImage **in, VipsImage **out, int n ); -int im__formatalike( VipsImage *in1, VipsImage *in2, VipsImage *out1, VipsImage *out2 ); -int im__sizealike_vec( VipsImage **in, VipsImage **out, int n ); -int im__sizealike( VipsImage *in1, VipsImage *in2, - VipsImage *out1, VipsImage *out2 ); - -int im__arith_binary( const char *domain, - VipsImage *in1, VipsImage *in2, VipsImage *out, - int format_table[10], - im_wrapmany_fn fn, void *b ); -int im__arith_binary_const( const char *domain, - VipsImage *in, VipsImage *out, - int n, double *c, VipsBandFormat vfmt, - int format_table[10], - im_wrapone_fn fn1, im_wrapone_fn fnn ); -int im__value( VipsImage *im, double *value ); -typedef int (*im__wrapscan_fn)( void *p, int n, void *seq, void *a, void *b ); -int im__wrapscan( VipsImage *in, - VipsStartFn start, im__wrapscan_fn scan, VipsStopFn stop, - void *a, void *b ); -int im__colour_difference( const char *domain, - VipsImage *in1, VipsImage *in2, VipsImage *out, - im_wrapmany_fn buffer_fn, void *a, void *b ); -int im__colour_unary( const char *domain, - VipsImage *in, VipsImage *out, VipsInterpretation interpretation, - im_wrapone_fn buffer_fn, void *a, void *b ); -VipsImage **im__insert_base( const char *domain, - VipsImage *in1, VipsImage *in2, VipsImage *out ); - -int im__find_lroverlap( VipsImage *ref_in, VipsImage *sec_in, VipsImage *out, - int bandno_in, - int xref, int yref, int xsec, int ysec, - int halfcorrelation, int halfarea, - int *dx0, int *dy0, - double *scale1, double *angle1, double *dx1, double *dy1 ); -int im__find_tboverlap( VipsImage *ref_in, VipsImage *sec_in, VipsImage *out, - int bandno_in, - int xref, int yref, int xsec, int ysec, - int halfcorrelation, int halfarea, - int *dx0, int *dy0, - double *scale1, double *angle1, double *dx1, double *dy1 ); -int im__find_best_contrast( VipsImage *image, - int xpos, int ypos, int xsize, int ysize, - int xarray[], int yarray[], int cont[], - int nbest, int hcorsize ); -int im__balance( VipsImage *ref, VipsImage *sec, VipsImage *out, - VipsImage **ref_out, VipsImage **sec_out, int dx, int dy, int balancetype ); - -void imb_LCh2Lab( float *, float *, int ); - -/* A colour temperature. - */ -typedef struct { - double X0, Y0, Z0; -} im_colour_temperature; - -void imb_XYZ2Lab( float *, float *, int, im_colour_temperature * ); -void imb_LabS2Lab( signed short *, float *, int ); -void imb_Lab2LabS( float *, signed short *, int n ); - -void vips__Lab2LabQ_vec( VipsPel *out, float *in, int width ); -void vips__LabQ2Lab_vec( float *out, VipsPel *in, int width ); - -void im_copy_dmask_matrix( DOUBLEMASK *mask, double **matrix ); -void im_copy_matrix_dmask( double **matrix, DOUBLEMASK *mask ); - -int *im_ivector(); -float *im_fvector(); -double *im_dvector(); -void im_free_ivector(); -void im_free_fvector(); -void im_free_dvector(); - -int **im_imat_alloc(); -float **im_fmat_alloc(); -double **im_dmat_alloc(); -void im_free_imat(); -void im_free_fmat(); -void im_free_dmat(); - -int im_invmat( double **, int ); - -int *im_offsets45( int size ); - -int im_conv_f_raw( VipsImage *in, VipsImage *out, DOUBLEMASK *mask ); -int im_convsep_f_raw( VipsImage *in, VipsImage *out, DOUBLEMASK *mask ); - /* draw */ VipsPel *vips__vector_to_ink( const char *domain, @@ -318,10 +216,9 @@ void vips_mosaicing_operation_init( void ); guint64 vips__parse_size( const char *size_string ); int vips__substitute( const char *domain, char *buf, size_t len, char *sub ); -IMAGE *vips__deprecated_open_read( const char *filename, gboolean sequential ); -IMAGE *vips__deprecated_open_write( const char *filename ); - -int vips__input_interpolate_init( im_object *obj, char *str ); +int vips_check_coding_labq( const char *domain, VipsImage *im ); +int vips_check_coding_rad( const char *domain, VipsImage *im ); +int vips_check_bands_3ormore( const char *domain, VipsImage *im ); #ifdef __cplusplus } diff --git a/libvips/include/vips/version.h.in b/libvips/include/vips/version.h.in index 13e3c13a..85a2a5ae 100644 --- a/libvips/include/vips/version.h.in +++ b/libvips/include/vips/version.h.in @@ -14,5 +14,6 @@ * it. */ #define VIPS_EXEEXT "@VIPS_EXEEXT@" +#define VIPS_ENABLE_DEPRECATED @VIPS_ENABLE_DEPRECATED@ #endif /*VIPS_VERSION_H*/ diff --git a/libvips/include/vips/vips.h b/libvips/include/vips/vips.h index 1eaf4237..79a51f74 100644 --- a/libvips/include/vips/vips.h +++ b/libvips/include/vips/vips.h @@ -147,16 +147,19 @@ extern "C" { #include #include -#ifndef VIPS_DISABLE_VIPS7COMPAT -#include -#endif /*VIPS_DISABLE_VIPS7COMPAT*/ - -#ifdef VIPS_ENABLE_DEPRECATED +/* This stuff is very, very old and should not be used by anyone now. + */ +#ifdef VIPS_ENABLE_ANCIENT #include -#endif /*VIPS_ENABLE_DEPRECATED*/ +#endif /*VIPS_ENABLE_ANCIENT*/ -#include +/* Still in use, but can be turned off. + */ +#if VIPS_ENABLE_DEPRECATED +#include #include +#include +#endif /*VIPS_ENABLE_DEPRECATED*/ /* We can't use _ here since this will be compiled by our clients and they may * not have _(). diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 2bfab013..cc275eb4 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -442,10 +442,6 @@ G_STMT_START { \ #define im__change_suffix vips__change_suffix -int vips_check_coding_labq( const char *domain, VipsImage *im ); -int vips_check_coding_rad( const char *domain, VipsImage *im ); -int vips_check_bands_3ormore( const char *domain, VipsImage *im ); - /* Buffer processing. */ typedef void (*im_wrapone_fn)( void *in, void *out, int width, @@ -1106,6 +1102,111 @@ int vips_foreign_load( const char *filename, VipsImage **out, ... ) int vips_foreign_save( VipsImage *in, const char *filename, ... ) __attribute__((sentinel)); +VipsImage *vips__deprecated_open_read( const char *filename, gboolean sequential ); +VipsImage *vips__deprecated_open_write( const char *filename ); + +void im__format_init( void ); + +void im__tiff_register( void ); +void im__jpeg_register( void ); +void im__png_register( void ); +void im__csv_register( void ); +void im__ppm_register( void ); +void im__analyze_register( void ); +void im__exr_register( void ); +void im__magick_register( void ); + +int im__bandup( const char *domain, VipsImage *in, VipsImage *out, int n ); +int im__bandalike_vec( const char *domain, VipsImage **in, VipsImage **out, int n ); +int im__bandalike( const char *domain, + VipsImage *in1, VipsImage *in2, VipsImage *out1, VipsImage *out2 ); +int im__formatalike_vec( VipsImage **in, VipsImage **out, int n ); +int im__formatalike( VipsImage *in1, VipsImage *in2, VipsImage *out1, VipsImage *out2 ); +int im__sizealike_vec( VipsImage **in, VipsImage **out, int n ); +int im__sizealike( VipsImage *in1, VipsImage *in2, + VipsImage *out1, VipsImage *out2 ); + +int im__arith_binary( const char *domain, + VipsImage *in1, VipsImage *in2, VipsImage *out, + int format_table[10], + im_wrapmany_fn fn, void *b ); +int im__arith_binary_const( const char *domain, + VipsImage *in, VipsImage *out, + int n, double *c, VipsBandFormat vfmt, + int format_table[10], + im_wrapone_fn fn1, im_wrapone_fn fnn ); +int im__value( VipsImage *im, double *value ); +typedef int (*im__wrapscan_fn)( void *p, int n, void *seq, void *a, void *b ); +int im__wrapscan( VipsImage *in, + VipsStartFn start, im__wrapscan_fn scan, VipsStopFn stop, + void *a, void *b ); +int im__colour_difference( const char *domain, + VipsImage *in1, VipsImage *in2, VipsImage *out, + im_wrapmany_fn buffer_fn, void *a, void *b ); +int im__colour_unary( const char *domain, + VipsImage *in, VipsImage *out, VipsInterpretation interpretation, + im_wrapone_fn buffer_fn, void *a, void *b ); +VipsImage **im__insert_base( const char *domain, + VipsImage *in1, VipsImage *in2, VipsImage *out ); + +int im__find_lroverlap( VipsImage *ref_in, VipsImage *sec_in, VipsImage *out, + int bandno_in, + int xref, int yref, int xsec, int ysec, + int halfcorrelation, int halfarea, + int *dx0, int *dy0, + double *scale1, double *angle1, double *dx1, double *dy1 ); +int im__find_tboverlap( VipsImage *ref_in, VipsImage *sec_in, VipsImage *out, + int bandno_in, + int xref, int yref, int xsec, int ysec, + int halfcorrelation, int halfarea, + int *dx0, int *dy0, + double *scale1, double *angle1, double *dx1, double *dy1 ); +int im__find_best_contrast( VipsImage *image, + int xpos, int ypos, int xsize, int ysize, + int xarray[], int yarray[], int cont[], + int nbest, int hcorsize ); +int im__balance( VipsImage *ref, VipsImage *sec, VipsImage *out, + VipsImage **ref_out, VipsImage **sec_out, int dx, int dy, int balancetype ); + +void imb_LCh2Lab( float *, float *, int ); + +/* A colour temperature. + */ +typedef struct { + double X0, Y0, Z0; +} im_colour_temperature; + +void imb_XYZ2Lab( float *, float *, int, im_colour_temperature * ); +void imb_LabS2Lab( signed short *, float *, int ); +void imb_Lab2LabS( float *, signed short *, int n ); + +void vips__Lab2LabQ_vec( VipsPel *out, float *in, int width ); +void vips__LabQ2Lab_vec( float *out, VipsPel *in, int width ); + +void im_copy_dmask_matrix( DOUBLEMASK *mask, double **matrix ); +void im_copy_matrix_dmask( double **matrix, DOUBLEMASK *mask ); + +int *im_ivector(); +float *im_fvector(); +double *im_dvector(); +void im_free_ivector(); +void im_free_fvector(); +void im_free_dvector(); + +int **im_imat_alloc(); +float **im_fmat_alloc(); +double **im_dmat_alloc(); +void im_free_imat(); +void im_free_fmat(); +void im_free_dmat(); + +int im_invmat( double **, int ); + +int *im_offsets45( int size ); + +int im_conv_f_raw( VipsImage *in, VipsImage *out, DOUBLEMASK *mask ); +int im_convsep_f_raw( VipsImage *in, VipsImage *out, DOUBLEMASK *mask ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/mosaicing/im_lrmerge.c b/libvips/mosaicing/im_lrmerge.c index 73c6ed5e..dd7e1078 100644 --- a/libvips/mosaicing/im_lrmerge.c +++ b/libvips/mosaicing/im_lrmerge.c @@ -187,7 +187,7 @@ find_first( REGION *ir, int *pos, int x, int y, int w ) /* Double the number of bands in a complex. */ - if( vips_bandfmt_iscomplex( im->BandFmt ) ) + if( vips_band_format_iscomplex( im->BandFmt ) ) ne *= 2; /* Search for the first non-zero band element from the left edge of the image. @@ -236,7 +236,7 @@ find_last( REGION *ir, int *pos, int x, int y, int w ) /* Double the number of bands in a complex. */ - if( vips_bandfmt_iscomplex( im->BandFmt ) ) + if( vips_band_format_iscomplex( im->BandFmt ) ) ne *= 2; /* Search for the first non-zero band element from the right. diff --git a/libvips/mosaicing/im_tbmerge.c b/libvips/mosaicing/im_tbmerge.c index eab53e18..0ed89926 100644 --- a/libvips/mosaicing/im_tbmerge.c +++ b/libvips/mosaicing/im_tbmerge.c @@ -129,7 +129,7 @@ find_top( REGION *ir, int *pos, int x, int y, int h ) /* Double the number of bands in a complex. */ - if( vips_bandfmt_iscomplex( im->BandFmt ) ) + if( vips_band_format_iscomplex( im->BandFmt ) ) b *= 2; /* Search for the first non-zero band element from the top edge of the image. @@ -183,7 +183,7 @@ find_bot( REGION *ir, int *pos, int x, int y, int h ) /* Double the number of bands in a complex. */ - if( vips_bandfmt_iscomplex( im->BandFmt ) ) + if( vips_band_format_iscomplex( im->BandFmt ) ) b *= 2; /* Search for the first non-zero band element from the top edge of the image. diff --git a/libvips/resample/lbb.cpp b/libvips/resample/lbb.cpp index c664460a..a678174b 100644 --- a/libvips/resample/lbb.cpp +++ b/libvips/resample/lbb.cpp @@ -797,7 +797,8 @@ vips_interpolate_lbb_interpolate( VipsInterpolate* restrict interpolate, */ const int actual_bands = in->im->Bands; const int bands = - vips_bandfmt_iscomplex( in->im->BandFmt ) ? 2 * actual_bands : actual_bands; + vips_band_format_iscomplex( in->im->BandFmt ) ? + 2 * actual_bands : actual_bands; /* Confirm that absolute_x and absolute_y are >= 1, see above. */ diff --git a/libvips/resample/nohalo.cpp b/libvips/resample/nohalo.cpp index 374ab2bd..332b1786 100644 --- a/libvips/resample/nohalo.cpp +++ b/libvips/resample/nohalo.cpp @@ -1518,7 +1518,8 @@ vips_interpolate_nohalo_interpolate( VipsInterpolate* restrict interpolate, */ const int actual_bands = in->im->Bands; const int bands = - vips_bandfmt_iscomplex( in->im->BandFmt ) ? 2 * actual_bands : actual_bands; + vips_band_format_iscomplex( in->im->BandFmt ) ? + 2 * actual_bands : actual_bands; /* Confirm that absolute_x and absolute_y are >= 2, see above. */ diff --git a/libvips/resample/shrink.c b/libvips/resample/shrink.c index 0604f4d5..c76c5076 100644 --- a/libvips/resample/shrink.c +++ b/libvips/resample/shrink.c @@ -135,7 +135,7 @@ vips_shrink_start( VipsImage *out, void *a, void *b ) VipsShrink *shrink = (VipsShrink *) b; VipsShrinkSequence *seq; - if( !(seq = IM_NEW( out, VipsShrinkSequence )) ) + if( !(seq = VIPS_NEW( out, VipsShrinkSequence )) ) return( NULL ); seq->ir = vips_region_new( in ); diff --git a/libvips/resample/transform.c b/libvips/resample/transform.c index ccece97f..b620b70e 100644 --- a/libvips/resample/transform.c +++ b/libvips/resample/transform.c @@ -187,8 +187,8 @@ typedef void (*transform_fn)( const VipsTransformation *, */ static void transform_rect( const VipsTransformation *trn, transform_fn transform, - const Rect *in, /* In input space */ - Rect *out ) /* In output space */ + const VipsRect *in, /* In input space */ + VipsRect *out ) /* In output space */ { double x1, y1; /* Map corners */ double x2, y2; @@ -196,25 +196,26 @@ transform_rect( const VipsTransformation *trn, transform_fn transform, double x4, y4; double left, right, top, bottom; - /* Map input Rect. + /* Map input VipsRect. */ transform( trn, in->left, in->top, &x1, &y1 ); - transform( trn, in->left, IM_RECT_BOTTOM( in ), &x3, &y3 ); - transform( trn, IM_RECT_RIGHT( in ), in->top, &x2, &y2 ); - transform( trn, IM_RECT_RIGHT( in ), IM_RECT_BOTTOM( in ), &x4, &y4 ); + transform( trn, in->left, VIPS_RECT_BOTTOM( in ), &x3, &y3 ); + transform( trn, VIPS_RECT_RIGHT( in ), in->top, &x2, &y2 ); + transform( trn, VIPS_RECT_RIGHT( in ), VIPS_RECT_BOTTOM( in ), + &x4, &y4 ); /* Find bounding box for these four corners. Round-to-nearest to try * to stop rounding errors growing images. */ - left = IM_MIN( x1, IM_MIN( x2, IM_MIN( x3, x4 ) ) ); - right = IM_MAX( x1, IM_MAX( x2, IM_MAX( x3, x4 ) ) ); - top = IM_MIN( y1, IM_MIN( y2, IM_MIN( y3, y4 ) ) ); - bottom = IM_MAX( y1, IM_MAX( y2, IM_MAX( y3, y4 ) ) ); + left = VIPS_MIN( x1, VIPS_MIN( x2, VIPS_MIN( x3, x4 ) ) ); + right = VIPS_MAX( x1, VIPS_MAX( x2, VIPS_MAX( x3, x4 ) ) ); + top = VIPS_MIN( y1, VIPS_MIN( y2, VIPS_MIN( y3, y4 ) ) ); + bottom = VIPS_MAX( y1, VIPS_MAX( y2, VIPS_MAX( y3, y4 ) ) ); - out->left = IM_RINT( left ); - out->top = IM_RINT( top ); - out->width = IM_RINT( right - left ); - out->height = IM_RINT( bottom - top ); + out->left = VIPS_RINT( left ); + out->top = VIPS_RINT( top ); + out->width = VIPS_RINT( right - left ); + out->height = VIPS_RINT( bottom - top ); } /* Given an area in the input image, calculate the bounding box for those @@ -222,8 +223,8 @@ transform_rect( const VipsTransformation *trn, transform_fn transform, */ void vips__transform_forward_rect( const VipsTransformation *trn, - const Rect *in, /* In input space */ - Rect *out ) /* In output space */ + const VipsRect *in, /* In input space */ + VipsRect *out ) /* In output space */ { transform_rect( trn, vips__transform_forward_point, in, out ); } @@ -233,8 +234,8 @@ vips__transform_forward_rect( const VipsTransformation *trn, */ void vips__transform_invert_rect( const VipsTransformation *trn, - const Rect *in, /* In output space */ - Rect *out ) /* In input space */ + const VipsRect *in, /* In output space */ + VipsRect *out ) /* In input space */ { transform_rect( trn, vips__transform_invert_point, in, out ); } diff --git a/libvips/resample/vsqbs.cpp b/libvips/resample/vsqbs.cpp index a028094a..528b2b30 100644 --- a/libvips/resample/vsqbs.cpp +++ b/libvips/resample/vsqbs.cpp @@ -304,7 +304,7 @@ extern "C" { static void vips_interpolate_vsqbs_interpolate( VipsInterpolate* restrict interpolate, void* restrict out, - REGION* restrict in, + VipsRegion* restrict in, double absolute_x, double absolute_y ) { @@ -338,7 +338,8 @@ vips_interpolate_vsqbs_interpolate( VipsInterpolate* restrict interpolate, */ const int actual_bands = in->im->Bands; const int bands = - vips_bandfmt_iscomplex( in->im->BandFmt ) ? 2 * actual_bands : actual_bands; + vips_band_format_iscomplex( in->im->BandFmt ) ? + 2 * actual_bands : actual_bands; /* Confirm that absolute_x and absolute_y are >= 1, see above. */ diff --git a/tools/Makefile.am b/tools/Makefile.am index d5566305..c9e5b112 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -23,11 +23,11 @@ bin_SCRIPTS = \ batch_rubber_sheet \ batch_crop \ vipsprofile \ - vips-7.40 + vips-7.41 EXTRA_DIST = \ vipsprofile \ - vips-7.40 \ + vips-7.41 \ light_correct.in \ shrink_width.in \ batch_image_convert.in \ diff --git a/tools/vips-7.40 b/tools/vips-7.41 similarity index 100% rename from tools/vips-7.40 rename to tools/vips-7.41