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;