revise cast again
fixes saturated cast to integer
This commit is contained in:
parent
b9eddecca3
commit
2265ad70a3
@ -126,10 +126,11 @@ G_DEFINE_TYPE( VipsCast, vips_cast, VIPS_TYPE_CONVERSION );
|
||||
#define CAST_SHORT( X ) VIPS_CLIP( SHRT_MIN, (X), SHRT_MAX )
|
||||
|
||||
/* We know the source cannot be the same as the dest, so we will only use
|
||||
* CAST_UINT() for an INT source, and vice versa.
|
||||
* CAST_UINT() for an INT source, and vice versa. We don't need to clip to
|
||||
* INT_MAX, since float->int does that for us.
|
||||
*/
|
||||
#define CAST_UINT( X ) VIPS_MAX( 0, (X) )
|
||||
#define CAST_INT( X ) VIPS_MIN( (X), INT_MAX )
|
||||
#define CAST_INT( X ) (X)
|
||||
|
||||
/* Rightshift an integer type, ie. sizeof(ITYPE) > sizeof(OTYPE).
|
||||
*/
|
||||
@ -222,7 +223,7 @@ G_DEFINE_TYPE( VipsCast, vips_cast, VIPS_TYPE_CONVERSION );
|
||||
OTYPE * restrict q = (OTYPE *) out; \
|
||||
\
|
||||
for( x = 0; x < sz; x++ ) \
|
||||
q[x] = p[x]; \
|
||||
q[x] = CAST( p[x] ); \
|
||||
}
|
||||
|
||||
/* Cast complex types to an int type. Just take the real part.
|
||||
@ -232,7 +233,7 @@ G_DEFINE_TYPE( VipsCast, vips_cast, VIPS_TYPE_CONVERSION );
|
||||
OTYPE * restrict q = (OTYPE *) out; \
|
||||
\
|
||||
for( x = 0; x < sz; x++ ) { \
|
||||
q[x] = p[0]; \
|
||||
q[x] = CAST( p[0] ); \
|
||||
p += 2; \
|
||||
} \
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user