clip bicubic output range from int

The output range of the bicubic interpolator is outside the input range,
we must clip from a larger type.

See https://github.com/jcupitt/libvips/pull/372
This commit is contained in:
John Cupitt 2016-01-23 10:09:11 +00:00
parent 0dd7f14ada
commit 31e4168718
1 changed files with 8 additions and 10 deletions

View File

@ -153,17 +153,16 @@ bicubic_unsigned_int_tab( void *pout, const VipsPel *pin,
const T qua_thr = in[l3_plus_b2];
const T qua_fou = in[l3_plus_b3];
out[z] = bicubic_unsigned_int<T>(
int bicubic = bicubic_unsigned_int<T>(
uno_one, uno_two, uno_thr, uno_fou,
dos_one, dos_two, dos_thr, dos_fou,
tre_one, tre_two, tre_thr, tre_fou,
qua_one, qua_two, qua_thr, qua_fou,
cx, cy );
if( out[z] < 0 )
out[z] = 0;
else if( out[z] > max_value )
out[z] = max_value;
bicubic = VIPS_CLIP( 0, bicubic, max_value );
out[z] = bicubic;
in += 1;
}
@ -217,17 +216,16 @@ bicubic_signed_int_tab( void *pout, const VipsPel *pin,
const T qua_thr = in[l3_plus_b2];
const T qua_fou = in[l3_plus_b3];
out[z] = bicubic_signed_int<T>(
int bicubic = bicubic_signed_int<T>(
uno_one, uno_two, uno_thr, uno_fou,
dos_one, dos_two, dos_thr, dos_fou,
tre_one, tre_two, tre_thr, tre_fou,
qua_one, qua_two, qua_thr, qua_fou,
cx, cy );
if( out[z] < min_value )
out[z] = min_value;
else if( out[z] > max_value )
out[z] = max_value;
bicubic = VIPS_CLIP( min_value, bicubic, max_value );
out[z] = bicubic;
in += 1;
}