remove vips_recip()
it wasn't really necessary, and it was rather slow
This commit is contained in:
parent
a4d89b852a
commit
0623a05f48
@ -81,7 +81,7 @@ G_DEFINE_TYPE( VipsUnpremultiply, vips_unpremultiply, VIPS_TYPE_CONVERSION );
|
||||
\
|
||||
for( x = 0; x < width; x++ ) { \
|
||||
IN alpha = p[alpha_band]; \
|
||||
OUT factor = max_alpha * vips_recip( alpha ); \
|
||||
OUT factor = alpha == 0 ? 0 : max_alpha / alpha; \
|
||||
\
|
||||
for( i = 0; i < alpha_band; i++ ) \
|
||||
q[i] = factor * p[i]; \
|
||||
@ -102,7 +102,7 @@ G_DEFINE_TYPE( VipsUnpremultiply, vips_unpremultiply, VIPS_TYPE_CONVERSION );
|
||||
\
|
||||
for( x = 0; x < width; x++ ) { \
|
||||
IN alpha = p[3]; \
|
||||
OUT factor = max_alpha * vips_recip( alpha ); \
|
||||
OUT factor = alpha == 0 ? 0 : max_alpha / alpha; \
|
||||
\
|
||||
q[0] = factor * p[0]; \
|
||||
q[1] = factor * p[1]; \
|
||||
|
@ -84,20 +84,6 @@ extern "C" {
|
||||
#define VIPS_FMIN( A, B ) VIPS_MIN( A, B )
|
||||
#endif
|
||||
|
||||
/* Calculate 1.0 / x, avoiding division by zero when near zero.
|
||||
*/
|
||||
static inline double
|
||||
vips_recip( double x )
|
||||
{
|
||||
static const double epsilon = 1e-10;
|
||||
|
||||
int sign = x < 0.0 ? -1.0 : 1.0;
|
||||
|
||||
return( sign * x >= epsilon ?
|
||||
1.0 / x :
|
||||
sign / epsilon );
|
||||
}
|
||||
|
||||
/* Testing status before the function call saves a lot of time.
|
||||
*/
|
||||
#define VIPS_ONCE( ONCE, FUNC, CLIENT ) \
|
||||
|
Loading…
Reference in New Issue
Block a user