fix int overflow in shrinkv
This commit is contained in:
parent
cfe0857ae1
commit
3c8a9815ba
|
@ -199,12 +199,13 @@ vips_shrinkv_add_line( VipsShrinkv *shrink, VipsShrinkvSequence *seq,
|
||||||
|
|
||||||
/* Integer average.
|
/* Integer average.
|
||||||
*/
|
*/
|
||||||
#define IAVG( TYPE ) { \
|
#define IAVG( TYPE, BTYPE ) { \
|
||||||
int * restrict sum = (int *) seq->sum; \
|
int * restrict sum = (int *) seq->sum; \
|
||||||
TYPE * restrict q = (TYPE *) out; \
|
TYPE * restrict q = (TYPE *) out; \
|
||||||
\
|
\
|
||||||
for( x = 0; x < sz; x++ ) \
|
for( x = 0; x < sz; x++ ) \
|
||||||
q[x] = (sum[x] + shrink->vshrink / 2) / shrink->vshrink; \
|
q[x] = ((BTYPE) sum[x] + shrink->vshrink / 2) / \
|
||||||
|
shrink->vshrink; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Float average.
|
/* Float average.
|
||||||
|
@ -234,17 +235,17 @@ vips_shrinkv_write_line( VipsShrinkv *shrink, VipsShrinkvSequence *seq,
|
||||||
VipsPel *out = VIPS_REGION_ADDR( or, left, top );
|
VipsPel *out = VIPS_REGION_ADDR( or, left, top );
|
||||||
switch( resample->in->BandFmt ) {
|
switch( resample->in->BandFmt ) {
|
||||||
case VIPS_FORMAT_UCHAR:
|
case VIPS_FORMAT_UCHAR:
|
||||||
IAVG( unsigned char ); break;
|
IAVG( unsigned char, int ); break;
|
||||||
case VIPS_FORMAT_CHAR:
|
case VIPS_FORMAT_CHAR:
|
||||||
IAVG( char ); break;
|
IAVG( char, int ); break;
|
||||||
case VIPS_FORMAT_USHORT:
|
case VIPS_FORMAT_USHORT:
|
||||||
IAVG( unsigned short ); break;
|
IAVG( unsigned short, int ); break;
|
||||||
case VIPS_FORMAT_SHORT:
|
case VIPS_FORMAT_SHORT:
|
||||||
IAVG( short ); break;
|
IAVG( short, int ); break;
|
||||||
case VIPS_FORMAT_UINT:
|
case VIPS_FORMAT_UINT:
|
||||||
IAVG( unsigned int ); break;
|
IAVG( unsigned int, int ); break;
|
||||||
case VIPS_FORMAT_INT:
|
case VIPS_FORMAT_INT:
|
||||||
IAVG( int ); break;
|
IAVG( int, gint64 ); break;
|
||||||
case VIPS_FORMAT_FLOAT:
|
case VIPS_FORMAT_FLOAT:
|
||||||
FAVG( float ); break;
|
FAVG( float ); break;
|
||||||
case VIPS_FORMAT_DOUBLE:
|
case VIPS_FORMAT_DOUBLE:
|
||||||
|
|
Loading…
Reference in New Issue