Improve greyscale perf by using isinf/isnan after calc

This commit is contained in:
Lovell Fuller 2018-01-02 20:36:14 +00:00
parent 4c2434ab67
commit 768ab7fa8f

View File

@ -350,24 +350,19 @@ vips_col_scRGB2BW( int range, int *lut, float R, float G, float B,
int Yi;
float v;
/* RGB can be Nan, Inf etc. Throw those values out, they will break
* our clipping.
*
* Don't use isnormal(), it is false for 0.0 and for subnormal
* numbers.
/* The usual ratio. We do this in linear space before we gamma.
*/
if( VIPS_ISNAN( R ) || VIPS_ISINF( R ) ||
VIPS_ISNAN( G ) || VIPS_ISINF( G ) ||
VIPS_ISNAN( B ) || VIPS_ISINF( B ) ) {
Y = 0.2 * R + 0.7 * G + 0.1 * B;
/* Y can be Nan, Inf etc. Throw those values out, they will break
* our clipping.
*/
if( VIPS_ISNAN( Y ) || VIPS_ISINF( Y ) ) {
*g = 0;
return( -1 );
}
/* The usual ratio. We do this in linear space before we gamma.
*/
Y = 0.2 * R + 0.7 * G + 0.1 * B;
/* Look up with a float index: interpolate between the nearest two
* points.
*