From fb489bad538bfb1a89b70d3c9d6d3843c04f4467 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 3 Feb 2014 14:29:57 +0000 Subject: [PATCH 1/2] move vips_image_decode() into the public API --- ChangeLog | 2 +- TODO | 17 ----------------- libvips/arithmetic/arithmetic.c | 2 +- libvips/arithmetic/statistic.c | 2 +- libvips/colour/colour.c | 4 ++-- libvips/conversion/bandary.c | 2 +- libvips/conversion/cast.c | 2 +- libvips/conversion/falsecolour.c | 2 +- libvips/conversion/flatten.c | 2 +- libvips/conversion/recomb.c | 2 +- libvips/convolution/conv.c | 2 +- libvips/freqfilt/fwfft.c | 2 +- libvips/freqfilt/invfft.c | 2 +- libvips/histogram/hist_local.c | 2 +- libvips/histogram/histogram.c | 2 +- libvips/histogram/stdif.c | 2 +- libvips/include/vips/image.h | 2 ++ libvips/include/vips/internal.h | 2 -- libvips/iofuncs/image.c | 31 +++++++++++++++++++++++++++++++ libvips/morphology/morph.c | 2 +- libvips/morphology/rank.c | 2 +- libvips/resample/affine.c | 23 +---------------------- libvips/resample/shrink.c | 2 +- 23 files changed, 53 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index a97c1924..7a6adf91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 21/1/14 started 7.39.0 -- auto-decode for (almost) all operations +- auto-decode for (almost) all operations, see vips_image_decode() - background render thread cleans up and quits neatly - colourspace has a source_space option - operations can be tagged as "deprecated" diff --git a/TODO b/TODO index 3831bfd4..2bf0c0a2 100644 --- a/TODO +++ b/TODO @@ -1,21 +1,4 @@ -- check_uncoded() left to do: - - resample/quadratic.c - -- move vips__image_decode() into the public API - -- we vips_image_write() a lot, could we do this by - - int - vips_image_write( in, out ) - { - g_object_ref( in) - vips_object_local( out,in ) - } - - i.e. do everything at pipe build time - - inplace can we set a region for the pixels we will modify? diff --git a/libvips/arithmetic/arithmetic.c b/libvips/arithmetic/arithmetic.c index a8aea1de..e273cea0 100644 --- a/libvips/arithmetic/arithmetic.c +++ b/libvips/arithmetic/arithmetic.c @@ -539,7 +539,7 @@ vips_arithmetic_build( VipsObject *object ) /* Decode RAD/LABQ etc. */ for( i = 0; i < arithmetic->n; i++ ) - if( vips__image_decode( arithmetic->in[i], &decode[i] ) ) + if( vips_image_decode( arithmetic->in[i], &decode[i] ) ) return( -1 ); /* Cast our input images up to a common format, bands and size. diff --git a/libvips/arithmetic/statistic.c b/libvips/arithmetic/statistic.c index 1ab1cc2f..e4553c5f 100644 --- a/libvips/arithmetic/statistic.c +++ b/libvips/arithmetic/statistic.c @@ -123,7 +123,7 @@ vips_statistic_build( VipsObject *object ) statistic->ready = statistic->in; - if( vips__image_decode( statistic->ready, &t[0] ) ) + if( vips_image_decode( statistic->ready, &t[0] ) ) return( -1 ); statistic->ready = t[0]; diff --git a/libvips/colour/colour.c b/libvips/colour/colour.c index 3645dc88..0ea7e6ee 100644 --- a/libvips/colour/colour.c +++ b/libvips/colour/colour.c @@ -628,13 +628,13 @@ vips_colour_difference_build( VipsObject *object ) extra = NULL; if( left ) { - if( vips__image_decode( left, &t[0] ) ) + if( vips_image_decode( left, &t[0] ) ) return( -1 ); left = t[0]; } if( right ) { - if( vips__image_decode( right, &t[1] ) ) + if( vips_image_decode( right, &t[1] ) ) return( -1 ); right = t[1]; } diff --git a/libvips/conversion/bandary.c b/libvips/conversion/bandary.c index 06ede11a..2bda6da4 100644 --- a/libvips/conversion/bandary.c +++ b/libvips/conversion/bandary.c @@ -146,7 +146,7 @@ vips_bandary_build( VipsObject *object ) size = (VipsImage **) vips_object_local_array( object, bandary->n ); for( i = 0; i < bandary->n; i++ ) - if( vips__image_decode( bandary->in[i], &decode[i] ) ) + if( vips_image_decode( bandary->in[i], &decode[i] ) ) return( -1 ); if( vips__formatalike_vec( decode, format, bandary->n ) || vips__sizealike_vec( format, size, bandary->n ) ) diff --git a/libvips/conversion/cast.c b/libvips/conversion/cast.c index 9a080fdb..eadcefaa 100644 --- a/libvips/conversion/cast.c +++ b/libvips/conversion/cast.c @@ -446,7 +446,7 @@ vips_cast_build( VipsObject *object ) if( in->BandFmt == cast->format ) return( vips_image_write( in, conversion->out ) ); - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/conversion/falsecolour.c b/libvips/conversion/falsecolour.c index 867e6fe2..630b5b2c 100644 --- a/libvips/conversion/falsecolour.c +++ b/libvips/conversion/falsecolour.c @@ -349,7 +349,7 @@ vips_falsecolour_build( VipsObject *object ) * want to work for images which aren't in a recognised space, like * MULTIBAND. */ - if( vips__image_decode( falsecolour->in, &t[1] ) || + if( vips_image_decode( falsecolour->in, &t[1] ) || vips_extract_band( t[1], &t[2], 0, NULL ) || vips_cast( t[2], &t[3], VIPS_FORMAT_UCHAR, NULL ) || vips_maplut( t[3], &t[4], t[0], NULL ) || diff --git a/libvips/conversion/flatten.c b/libvips/conversion/flatten.c index 1bf4626e..85baee21 100644 --- a/libvips/conversion/flatten.c +++ b/libvips/conversion/flatten.c @@ -311,7 +311,7 @@ vips_flatten_build( VipsObject *object ) in = flatten->in; - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/conversion/recomb.c b/libvips/conversion/recomb.c index 0e39beb9..6adee2dc 100644 --- a/libvips/conversion/recomb.c +++ b/libvips/conversion/recomb.c @@ -150,7 +150,7 @@ vips_recomb_build( VipsObject *object ) in = recomb->in; - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/convolution/conv.c b/libvips/convolution/conv.c index 151a23bb..48ebe4ec 100644 --- a/libvips/convolution/conv.c +++ b/libvips/convolution/conv.c @@ -94,7 +94,7 @@ vips_conv_build( VipsObject *object ) /* Unpack for processing. */ - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/freqfilt/fwfft.c b/libvips/freqfilt/fwfft.c index 813a5cc1..618f8db2 100644 --- a/libvips/freqfilt/fwfft.c +++ b/libvips/freqfilt/fwfft.c @@ -303,7 +303,7 @@ vips_fwfft_build( VipsObject *object ) in = freqfilt->in; - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/freqfilt/invfft.c b/libvips/freqfilt/invfft.c index 8b8611ee..e20e5822 100644 --- a/libvips/freqfilt/invfft.c +++ b/libvips/freqfilt/invfft.c @@ -216,7 +216,7 @@ vips_invfft_build( VipsObject *object ) in = freqfilt->in; - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/histogram/hist_local.c b/libvips/histogram/hist_local.c index 9243ec05..15c518f7 100644 --- a/libvips/histogram/hist_local.c +++ b/libvips/histogram/hist_local.c @@ -236,7 +236,7 @@ vips_hist_local_build( VipsObject *object ) in = local->in; - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/histogram/histogram.c b/libvips/histogram/histogram.c index 8064dfa7..e4edf5b2 100644 --- a/libvips/histogram/histogram.c +++ b/libvips/histogram/histogram.c @@ -143,7 +143,7 @@ vips_histogram_build( VipsObject *object ) g_object_set( histogram, "out", vips_image_new(), NULL ); for( i = 0; i < histogram->n; i++ ) - if( vips__image_decode( histogram->in[i], &decode[i] ) || + if( vips_image_decode( histogram->in[i], &decode[i] ) || vips_check_hist( class->nickname, decode[i] ) ) return( -1 ); diff --git a/libvips/histogram/stdif.c b/libvips/histogram/stdif.c index 0406bbd2..86521614 100644 --- a/libvips/histogram/stdif.c +++ b/libvips/histogram/stdif.c @@ -224,7 +224,7 @@ vips_stdif_build( VipsObject *object ) in = stdif->in; - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index 5a59cc86..34f8a617 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -430,6 +430,8 @@ VipsImage *vips_image_new_temp_file( const char *format ); int vips_image_write( VipsImage *image, VipsImage *out ); int vips_image_write_to_file( VipsImage *image, const char *filename ); +int vips_image_decode( VipsImage *in, VipsImage **out ); + gboolean vips_image_isMSBfirst( VipsImage *image ); gboolean vips_image_isfile( VipsImage *image ); gboolean vips_image_ispartial( VipsImage *image ); diff --git a/libvips/include/vips/internal.h b/libvips/include/vips/internal.h index e29d64df..39c233b6 100644 --- a/libvips/include/vips/internal.h +++ b/libvips/include/vips/internal.h @@ -297,8 +297,6 @@ IMAGE *vips__deprecated_open_write( const char *filename ); int vips__input_interpolate_init( im_object *obj, char *str ); -int vips__image_decode( VipsImage *in, VipsImage **out ); - #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/iofuncs/image.c b/libvips/iofuncs/image.c index e97bcdef..0b9cef78 100644 --- a/libvips/iofuncs/image.c +++ b/libvips/iofuncs/image.c @@ -1997,6 +1997,37 @@ vips_image_write_to_file( VipsImage *image, const char *filename ) return( 0 ); } +/** + * vips_image_decode: + * @in: image to decode + * @out: write to this image + * + * A convenience function to unpack to a format that we can compute with. + * @out->Coding is always VIPS_CODING_NONE. + * + * See also: vips_LabQ2LabS(), vips_rad2float(). + * + * Returns: 0 on success, or -1 on error. + */ +int +vips_image_decode( VipsImage *in, VipsImage **out ) +{ + if( in->Coding == VIPS_CODING_LABQ ) { + if( vips_LabQ2LabS( in, out, NULL ) ) + return( -1 ); + } + else if( in->Coding == VIPS_CODING_RAD ) { + if( vips_rad2float( in, out, NULL ) ) + return( -1 ); + } + else { + if( vips_copy( in, out, NULL ) ) + return( -1 ); + } + + return( 0 ); +} + /** * vips_image_isMSBfirst: * @image: image to test diff --git a/libvips/morphology/morph.c b/libvips/morphology/morph.c index 8ce26671..e8e037c5 100644 --- a/libvips/morphology/morph.c +++ b/libvips/morphology/morph.c @@ -93,7 +93,7 @@ vips_morph_build( VipsObject *object ) in = morphology->in; - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/morphology/rank.c b/libvips/morphology/rank.c index b88154a5..a6388918 100644 --- a/libvips/morphology/rank.c +++ b/libvips/morphology/rank.c @@ -341,7 +341,7 @@ vips_rank_build( VipsObject *object ) in = morphology->in; - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/resample/affine.c b/libvips/resample/affine.c index 7d17a06e..13659405 100644 --- a/libvips/resample/affine.c +++ b/libvips/resample/affine.c @@ -375,27 +375,6 @@ vips_affine_gen( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) return( 0 ); } -/* Unpack to a format that we can compute with. - */ -int -vips__image_decode( VipsImage *in, VipsImage **out ) -{ - if( in->Coding == VIPS_CODING_LABQ ) { - if( vips_LabQ2LabS( in, out, NULL ) ) - return( -1 ); - } - else if( in->Coding == VIPS_CODING_RAD ) { - if( vips_rad2float( in, out, NULL ) ) - return( -1 ); - } - else { - if( vips_copy( in, out, NULL ) ) - return( -1 ); - } - - return( 0 ); -} - static int vips_affine_build( VipsObject *object ) { @@ -485,7 +464,7 @@ vips_affine_build( VipsObject *object ) return( -1 ); } - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; diff --git a/libvips/resample/shrink.c b/libvips/resample/shrink.c index f27e4bf9..0604f4d5 100644 --- a/libvips/resample/shrink.c +++ b/libvips/resample/shrink.c @@ -347,7 +347,7 @@ vips_shrink_build( VipsObject *object ) /* Unpack for processing. */ - if( vips__image_decode( in, &t[0] ) ) + if( vips_image_decode( in, &t[0] ) ) return( -1 ); in = t[0]; From de0448b53d02137de7d90eb82b429c97ea61089d Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 4 Feb 2014 09:11:43 +0000 Subject: [PATCH 2/2] undeprecate VIPS_MASK_* ruby-vips was using them, thanks ahacking --- ChangeLog | 4 ++++ configure.ac | 6 +++--- libvips/include/vips/vips7compat.h | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9386b99..2c217da3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +22/1/14 started 7.38.3 +- undeprecate VIPS_MASK_IDEAL_HIGHPASS and friends, ruby-vips was using them, + thanks ahacking + 22/1/14 started 7.38.2 - auto RAD decode for affine - falsecolour was not working for some image types diff --git a/configure.ac b/configure.ac index 0850b6bc..b6464593 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.38.2], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [7.38.3], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ(2.62) @@ -17,7 +17,7 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [7]) m4_define([vips_minor_version], [38]) -m4_define([vips_micro_version], [2]) +m4_define([vips_micro_version], [3]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -37,7 +37,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date` # binary interface changes not backwards compatible?: reset age to 0 LIBRARY_CURRENT=37 -LIBRARY_REVISION=1 +LIBRARY_REVISION=2 LIBRARY_AGE=0 # patched into include/vips/version.h diff --git a/libvips/include/vips/vips7compat.h b/libvips/include/vips/vips7compat.h index 9cfbf64b..58903ded 100644 --- a/libvips/include/vips/vips7compat.h +++ b/libvips/include/vips/vips7compat.h @@ -962,6 +962,28 @@ typedef enum { IM_MASK_FRACTAL_FLT = 18 } ImMaskType; +/* We had them in the VIPS namespace for a while before deprecating them. + */ +#define VIPS_MASK_IDEAL_HIGHPASS IM_MASK_IDEAL_HIGHPASS +#define VIPS_MASK_IDEAL_LOWPASS IM_MASK_IDEAL_LOWPASS +#define VIPS_MASK_BUTTERWORTH_HIGHPASS IM_MASK_BUTTERWORTH_HIGHPASS +#define VIPS_MASK_BUTTERWORTH_LOWPASS IM_MASK_BUTTERWORTH_LOWPASS +#define VIPS_MASK_GAUSS_HIGHPASS IM_MASK_GAUSS_HIGHPASS +#define VIPS_MASK_GAUSS_LOWPASS IM_MASK_GAUSS_LOWPASS +#define VIPS_MASK_IDEAL_RINGPASS IM_MASK_IDEAL_RINGPASS +#define VIPS_MASK_IDEAL_RINGREJECT IM_MASK_IDEAL_RINGREJECT +#define VIPS_MASK_BUTTERWORTH_RINGPASS IM_MASK_BUTTERWORTH_RINGPASS +#define VIPS_MASK_BUTTERWORTH_RINGREJECT IM_MASK_BUTTERWORTH_RINGREJECT +#define VIPS_MASK_GAUSS_RINGPASS IM_MASK_GAUSS_RINGPASS +#define VIPS_MASK_GAUSS_RINGREJECT IM_MASK_GAUSS_RINGREJECT +#define VIPS_MASK_IDEAL_BANDPASS IM_MASK_IDEAL_BANDPASS +#define VIPS_MASK_IDEAL_BANDREJECT IM_MASK_IDEAL_BANDREJECT +#define VIPS_MASK_BUTTERWORTH_BANDPASS IM_MASK_BUTTERWORTH_BANDPASS +#define VIPS_MASK_BUTTERWORTH_BANDREJECT IM_MASK_BUTTERWORTH_BANDREJECT +#define VIPS_MASK_GAUSS_BANDPASS IM_MASK_GAUSS_BANDPASS +#define VIPS_MASK_GAUSS_BANDREJECT IM_MASK_GAUSS_BANDREJECT +#define VIPS_MASK_FRACTAL_FLT IM_MASK_FRACTAL_FLT + int im_flt_image_freq( VipsImage *in, VipsImage *out, ImMaskType flag, ... ); int im_create_fmask( VipsImage *out, int xsize, int ysize, ImMaskType flag, ... );