From e8c4188936a840a181d0b5fd95bf1de7be2c3b2c Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 10 Dec 2013 14:56:14 +0000 Subject: [PATCH 1/3] be more forgiving about x values buildlut() would fail if rounding moved some of your x values away from ints --- libvips/create/buildlut.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libvips/create/buildlut.c b/libvips/create/buildlut.c index a8a4d56b..da2b1000 100644 --- a/libvips/create/buildlut.c +++ b/libvips/create/buildlut.c @@ -14,6 +14,8 @@ * - gtkdoc * 2/7/13 * - convert to a class + * 10/12/13 + * - be more forgiving about x vales not quite integers */ /* @@ -125,12 +127,16 @@ vips_buildlut_build_init( VipsBuildlut *lut ) for( y = 0; y < lut->mat->Ysize; y++ ) { double v = *VIPS_MATRIX( lut->mat, 0, y ); - if( floor( v ) != v ) { + /* Allow for being a bit off. + */ + if( abs( v - VIPS_RINT( v ) ) > 0.001 ) { vips_error( class->nickname, - "%s", _( "x value not an int" ) ); + _( "x value row %d not an int" ), y ); return( -1 ); } + v = VIPS_RINT( v ); + if( v < xlow ) xlow = v; if( v > xhigh ) @@ -189,8 +195,8 @@ vips_buildlut_build_create( VipsBuildlut *lut ) */ for( b = 0; b < bands; b++ ) { for( i = 0; i < ysize - 1; i++ ) { - const int x1 = lut->data[i][0]; - const int x2 = lut->data[i + 1][0]; + const int x1 = VIPS_RINT( lut->data[i][0] ); + const int x2 = VIPS_RINT( lut->data[i + 1][0] ); const int dx = x2 - x1; const double y1 = lut->data[i][b + 1]; const double y2 = lut->data[i + 1][b + 1]; From 3f95520580327da54d55ce1671144cc65291a8bf Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 19 Dec 2013 10:05:49 +0000 Subject: [PATCH 2/3] fix vips_hist_match() it wasn't upcasting input to uint due to a mix-up with VipsHistogram --- ChangeLog | 7 ++++--- libvips/histogram/hist_match.c | 11 +++-------- libvips/histogram/histogram.c | 22 ++++++++++++++++++---- libvips/histogram/phistogram.h | 4 ++++ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f696cee..93025eb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,13 @@ -20/11/13 started 7.36.5 +20/11/13 started 7.36.5 - better cache sizing in unbuffered sequential mode - allow larger tile_size in dzsave - remove use of PATH_MAX to help gnu hurd +- fix vips_hist_match() -15/11/13 started 7.36.4 +15/11/13 started 7.36.4 - improve compat with im_init_world() -18/10/13 started 7.36.3 +18/10/13 started 7.36.3 - fix compiler warnings in ubuntu 13.10 - reverse similarity rotation direction to match the convention used elsewhere in vips diff --git a/libvips/histogram/hist_match.c b/libvips/histogram/hist_match.c index d6805da0..8f196385 100644 --- a/libvips/histogram/hist_match.c +++ b/libvips/histogram/hist_match.c @@ -14,6 +14,8 @@ * - small cleanups * 12/8/13 * - redone im_histspec() as a class, vips_hist_match() + * 19/12/13 + * - oop, upcast input */ /* @@ -138,13 +140,6 @@ vips_hist_match_build( VipsObject *object ) return( 0 ); } -#define UI VIPS_FORMAT_UINT - -static const VipsBandFormat vips_hist_match_format_table[10] = { -/* UC C US S UI I F X D DX */ - UI, UI, UI, UI, UI, UI, UI, UI, UI, UI -}; - static void vips_hist_match_class_init( VipsHistMatchClass *class ) { @@ -159,7 +154,7 @@ vips_hist_match_class_init( VipsHistMatchClass *class ) vobject_class->description = _( "match two histograms" ); vobject_class->build = vips_hist_match_build; - hclass->format_table = vips_hist_match_format_table; + hclass->input_format = VIPS_FORMAT_UINT; hclass->process = vips_hist_match_process; VIPS_ARG_IMAGE( class, "in", 1, diff --git a/libvips/histogram/histogram.c b/libvips/histogram/histogram.c index a2c024ef..7f4ead5c 100644 --- a/libvips/histogram/histogram.c +++ b/libvips/histogram/histogram.c @@ -145,11 +145,23 @@ vips_histogram_build( VipsObject *object ) vips_check_hist( class->nickname, histogram->in[i] ) ) return( -1 ); - /* Cast our input images up to a common format, bands and size. + /* Cast our input images up to a common format, bands and size. If + * input_format is set, cast to a fixed input type. */ - if( vips__formatalike_vec( histogram->in, format, histogram->n ) || - vips__bandalike_vec( class->nickname, - format, band, histogram->n, 1 ) || + if( hclass->input_format != VIPS_FORMAT_NOTSET ) { + for( i = 0; i < histogram->n; i++ ) + if( vips_cast( histogram->in[i], &format[i], + hclass->input_format, NULL ) ) + return( -1 ); + } + else { + if( vips__formatalike_vec( histogram->in, + format, histogram->n ) ) + return( -1 ); + } + + if( vips__bandalike_vec( class->nickname, + format, band, histogram->n, 1 ) || vips__hist_sizealike_vec( band, size, histogram->n ) ) return( -1 ); @@ -203,6 +215,8 @@ vips_histogram_class_init( VipsHistogramClass *class ) vobject_class->description = _( "histogram operations" ); vobject_class->build = vips_histogram_build; + class->input_format = VIPS_FORMAT_NOTSET; + /* Inputs set by subclassess. */ diff --git a/libvips/histogram/phistogram.h b/libvips/histogram/phistogram.h index 37d4a518..45ff77a8 100644 --- a/libvips/histogram/phistogram.h +++ b/libvips/histogram/phistogram.h @@ -81,6 +81,10 @@ typedef struct _VipsHistogramClass { */ const VipsBandFormat *format_table; + /* If not VIPS_FORMAT_NOTSET, upcast all ins to this. + */ + VipsBandFormat input_format; + VipsHistogramProcessFn process; } VipsHistogramClass; From c81654ad93cac79f98144c58369fb18e16381f44 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Thu, 9 Jan 2014 14:26:58 +0000 Subject: [PATCH 3/3] fix some clang warnings --- ChangeLog | 3 +++ configure.ac | 6 +++--- libvips/deprecated/im_analyze2vips.c | 3 ++- libvips/deprecated/im_exr2vips.c | 3 ++- libvips/deprecated/im_openslide2vips.c | 3 ++- libvips/deprecated/im_ppm2vips.c | 3 ++- libvips/deprecated/im_tiff2vips.c | 3 ++- libvips/foreign/ppm.c | 6 +++--- libvips/foreign/ppm.h | 2 +- libvips/foreign/radiance.c | 2 +- libvips/foreign/webp2vips.c | 2 +- libvips/include/vips/foreign.h | 4 ++-- libvips/include/vips/image.h | 2 +- libvips/iofuncs/enumtypes.c | 2 +- 14 files changed, 26 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93025eb4..701e5b10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +9/1/14 started 7.36.6 +- fix some clang compiler warnings + 20/11/13 started 7.36.5 - better cache sizing in unbuffered sequential mode - allow larger tile_size in dzsave diff --git a/configure.ac b/configure.ac index ea2ed891..04202784 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.36.5], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [7.36.6], [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], [36]) -m4_define([vips_micro_version], [5]) +m4_define([vips_micro_version], [6]) 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=35 -LIBRARY_REVISION=5 +LIBRARY_REVISION=6 LIBRARY_AGE=0 # patched into include/vips/version.h diff --git a/libvips/deprecated/im_analyze2vips.c b/libvips/deprecated/im_analyze2vips.c index 8b5646b7..f4d892c9 100644 --- a/libvips/deprecated/im_analyze2vips.c +++ b/libvips/deprecated/im_analyze2vips.c @@ -48,7 +48,8 @@ static VipsFormatFlags analyze_flags( const char *filename ) { - return( vips_foreign_flags( "analyzeload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "analyzeload", filename ) ); } static int diff --git a/libvips/deprecated/im_exr2vips.c b/libvips/deprecated/im_exr2vips.c index c5f1b081..81aee02c 100644 --- a/libvips/deprecated/im_exr2vips.c +++ b/libvips/deprecated/im_exr2vips.c @@ -74,7 +74,8 @@ exr_flags( const char *name ) im_filename_split( name, filename, mode ); - return( vips_foreign_flags( "openexrload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "openexrload", filename ) ); } static int diff --git a/libvips/deprecated/im_openslide2vips.c b/libvips/deprecated/im_openslide2vips.c index 88acd1ff..a1c27d58 100644 --- a/libvips/deprecated/im_openslide2vips.c +++ b/libvips/deprecated/im_openslide2vips.c @@ -110,7 +110,8 @@ openslide_flags( const char *name ) im_filename_split( name, filename, mode ); - return( vips_foreign_flags( "openslideload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "openslideload", filename ) ); } static int diff --git a/libvips/deprecated/im_ppm2vips.c b/libvips/deprecated/im_ppm2vips.c index 52ec532b..1108223c 100644 --- a/libvips/deprecated/im_ppm2vips.c +++ b/libvips/deprecated/im_ppm2vips.c @@ -63,7 +63,8 @@ isppm( const char *filename ) static VipsFormatFlags ppm_flags( const char *filename ) { - return( vips_foreign_flags( "ppmload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "ppmload", filename ) ); } static const char *ppm_suffs[] = { ".ppm", ".pgm", ".pbm", ".pfm", NULL }; diff --git a/libvips/deprecated/im_tiff2vips.c b/libvips/deprecated/im_tiff2vips.c index 1bb1c90d..eecfd5fb 100644 --- a/libvips/deprecated/im_tiff2vips.c +++ b/libvips/deprecated/im_tiff2vips.c @@ -132,7 +132,8 @@ tiff_flags( const char *name ) im_filename_split( name, filename, mode ); - return( vips_foreign_flags( "tiffload", filename ) ); + return( (VipsFormatFlags) + vips_foreign_flags( "tiffload", filename ) ); } static int diff --git a/libvips/foreign/ppm.c b/libvips/foreign/ppm.c index 8f49168a..95e0e544 100644 --- a/libvips/foreign/ppm.c +++ b/libvips/foreign/ppm.c @@ -512,14 +512,14 @@ vips__ppm_isppm( const char *filename ) /* ppm flags function. */ -VipsFormatFlags +VipsForeignFlags vips__ppm_flags( const char *filename ) { - VipsFormatFlags flags; + VipsForeignFlags flags; flags = 0; if( isppmmmap( filename ) ) - flags |= VIPS_FORMAT_PARTIAL; + flags |= VIPS_FOREIGN_PARTIAL; return( flags ); } diff --git a/libvips/foreign/ppm.h b/libvips/foreign/ppm.h index d672f3dd..5bbc5546 100644 --- a/libvips/foreign/ppm.h +++ b/libvips/foreign/ppm.h @@ -38,7 +38,7 @@ extern "C" { int vips__ppm_header( const char *name, VipsImage *out ); int vips__ppm_load( const char *name, VipsImage *out ); int vips__ppm_isppm( const char *filename ); -VipsFormatFlags vips__ppm_flags( const char *filename ); +VipsForeignFlags vips__ppm_flags( const char *filename ); extern const char *vips__ppm_suffs[]; int vips__ppm_save( VipsImage *in, const char *filename, diff --git a/libvips/foreign/radiance.c b/libvips/foreign/radiance.c index 78046233..2103053e 100644 --- a/libvips/foreign/radiance.c +++ b/libvips/foreign/radiance.c @@ -1108,7 +1108,7 @@ vips2rad_put_data_block( VipsRegion *region, Rect *area, void *a ) for( i = 0; i < area->height; i++ ) { VipsPel *p = VIPS_REGION_ADDR( region, 0, area->top + i ); - if( fwritecolrs( p, area->width, write->fout ) ) + if( fwritecolrs( (COLR *) p, area->width, write->fout ) ) return( -1 ); } diff --git a/libvips/foreign/webp2vips.c b/libvips/foreign/webp2vips.c index 4996e5c2..f58c8fc9 100644 --- a/libvips/foreign/webp2vips.c +++ b/libvips/foreign/webp2vips.c @@ -186,7 +186,7 @@ read_image( Read *read, VipsImage *out ) { VipsImage **t = (VipsImage **) vips_object_local_array( VIPS_OBJECT( out ), 3 ); - guint64 length; + gint64 length; void *data; int fd; webp_decoder decoder; diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index b3b1e79d..728db908 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -90,8 +90,8 @@ void *vips_foreign_map( const char *base, typedef enum /*< flags >*/ { VIPS_FOREIGN_NONE = 0, /* No flags set */ VIPS_FOREIGN_PARTIAL = 1, /* Lazy read OK (eg. tiled tiff) */ - VIPS_FOREIGN_SEQUENTIAL = 2, /* Top-to-bottom lazy read OK */ - VIPS_FOREIGN_BIGENDIAN = 4, /* Most-significant byte first */ + VIPS_FOREIGN_BIGENDIAN = 2, /* Most-significant byte first */ + VIPS_FOREIGN_SEQUENTIAL = 4, /* Top-to-bottom lazy read OK */ VIPS_FOREIGN_ALL = 7 /* All flags set */ } VipsForeignFlags; diff --git a/libvips/include/vips/image.h b/libvips/include/vips/image.h index 5ba8689b..96f279ba 100644 --- a/libvips/include/vips/image.h +++ b/libvips/include/vips/image.h @@ -238,7 +238,7 @@ typedef struct _VipsImage { * gint64 so that we can guarantee to work even on systems with * strange ideas about large files. */ - guint64 sizeof_header; + gint64 sizeof_header; /* If this is a large disc image, don't map the whole thing, instead * have a set of windows shared between the regions active on the diff --git a/libvips/iofuncs/enumtypes.c b/libvips/iofuncs/enumtypes.c index 1ec1cca0..0f3ba782 100644 --- a/libvips/iofuncs/enumtypes.c +++ b/libvips/iofuncs/enumtypes.c @@ -14,8 +14,8 @@ vips_foreign_flags_get_type( void ) static const GFlagsValue values[] = { {VIPS_FOREIGN_NONE, "VIPS_FOREIGN_NONE", "none"}, {VIPS_FOREIGN_PARTIAL, "VIPS_FOREIGN_PARTIAL", "partial"}, - {VIPS_FOREIGN_SEQUENTIAL, "VIPS_FOREIGN_SEQUENTIAL", "sequential"}, {VIPS_FOREIGN_BIGENDIAN, "VIPS_FOREIGN_BIGENDIAN", "bigendian"}, + {VIPS_FOREIGN_SEQUENTIAL, "VIPS_FOREIGN_SEQUENTIAL", "sequential"}, {VIPS_FOREIGN_ALL, "VIPS_FOREIGN_ALL", "all"}, {0, NULL, NULL} };