fix vips_divide() for int args

This commit is contained in:
John Cupitt 2012-04-06 12:09:53 +01:00
parent d8000bb1b5
commit d338d0fae6
3 changed files with 19 additions and 13 deletions

View File

@ -1,3 +1,6 @@
6/4/12 started 7.28.3
- vips_divide() failed for int arguments
13/3/12 started 7.28.2 13/3/12 started 7.28.2
- xres/yres tiffsave args were broken - xres/yres tiffsave args were broken

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below # also update the version number in the m4 macros below
AC_INIT(vips, 7.28.2, vipsip@jiscmail.ac.uk) AC_INIT(vips, 7.28.3, vipsip@jiscmail.ac.uk)
# required for gobject-introspection # required for gobject-introspection
AC_PREREQ(2.62) AC_PREREQ(2.62)
@ -15,7 +15,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning # user-visible library versioning
m4_define([vips_major_version], [7]) m4_define([vips_major_version], [7])
m4_define([vips_minor_version], [28]) m4_define([vips_minor_version], [28])
m4_define([vips_micro_version], [2]) m4_define([vips_micro_version], [3])
m4_define([vips_version], m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version]) [vips_major_version.vips_minor_version.vips_micro_version])
@ -35,7 +35,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date`
# interface changes not backwards compatible?: reset age to 0 # interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=31 LIBRARY_CURRENT=31
LIBRARY_REVISION=2 LIBRARY_REVISION=3
LIBRARY_AGE=16 LIBRARY_AGE=16
# patched into include/vips/version.h # patched into include/vips/version.h

View File

@ -30,6 +30,9 @@
* - rewrite as a class * - rewrite as a class
* 22/2/12 * 22/2/12
* - avoid /0 for complex as well * - avoid /0 for complex as well
* 6/4/12
* - fixed switch cases
* - fixed int operands with <1 result
*/ */
/* /*
@ -150,7 +153,7 @@ G_DEFINE_TYPE( VipsDivide, vips_divide, VIPS_TYPE_BINARY );
#endif /* USE_MODARG_DIV */ #endif /* USE_MODARG_DIV */
/* Real divide. /* Real divide. Cast in to OUT before divide so we work for float output.
*/ */
#define RLOOP( IN, OUT ) { \ #define RLOOP( IN, OUT ) { \
IN *left = (IN *) in[0]; \ IN *left = (IN *) in[0]; \
@ -158,10 +161,10 @@ G_DEFINE_TYPE( VipsDivide, vips_divide, VIPS_TYPE_BINARY );
OUT *q = (OUT *) out; \ OUT *q = (OUT *) out; \
\ \
for( x = 0; x < sz; x++ ) \ for( x = 0; x < sz; x++ ) \
if( right[x] == 0.0 ) \ if( right[x] == 0 ) \
q[x] = 0; \ q[x] = 0; \
else \ else \
q[x] = left[x] / right[x]; \ q[x] = (OUT) left[x] / (OUT) right[x]; \
} }
static void static void
@ -177,12 +180,12 @@ vips_divide_buffer( VipsArithmetic *arithmetic,
* below. * below.
*/ */
switch( vips_image_get_format( im ) ) { switch( vips_image_get_format( im ) ) {
case VIPS_FORMAT_CHAR: RLOOP( signed char, signed short ); break; case VIPS_FORMAT_CHAR: RLOOP( signed char, float ); break;
case VIPS_FORMAT_UCHAR: RLOOP( unsigned char, signed short ); break; case VIPS_FORMAT_UCHAR: RLOOP( unsigned char, float ); break;
case VIPS_FORMAT_SHORT: RLOOP( signed short, signed int ); break; case VIPS_FORMAT_SHORT: RLOOP( signed short, float ); break;
case VIPS_FORMAT_USHORT:RLOOP( unsigned short, signed int ); break; case VIPS_FORMAT_USHORT: RLOOP( unsigned short, float ); break;
case VIPS_FORMAT_INT: RLOOP( signed int, signed int ); break; case VIPS_FORMAT_INT: RLOOP( signed int, float ); break;
case VIPS_FORMAT_UINT: RLOOP( unsigned int, signed int ); break; case VIPS_FORMAT_UINT: RLOOP( unsigned int, float ); break;
case VIPS_FORMAT_FLOAT: RLOOP( float, float ); break; case VIPS_FORMAT_FLOAT: RLOOP( float, float ); break;
case VIPS_FORMAT_DOUBLE: RLOOP( double, double ); break; case VIPS_FORMAT_DOUBLE: RLOOP( double, double ); break;
@ -235,7 +238,7 @@ vips_divide_init( VipsDivide *divide )
} }
/** /**
* vips_divide:: * vips_divide:
* @in1: input image 1 * @in1: input image 1
* @in2: input image 2 * @in2: input image 2
* @out: output image * @out: output image