Perf: improve conversion to LCH by ~30%, avoid costly atan2
This commit is contained in:
parent
72ca38cab0
commit
a7357c5757
@ -63,11 +63,6 @@ vips_col_ab2h( double a, double b )
|
|||||||
{
|
{
|
||||||
double h;
|
double h;
|
||||||
|
|
||||||
#ifdef HAVE_ATAN2
|
|
||||||
h = VIPS_DEG( atan2( b, a ) );
|
|
||||||
if( h < 0.0 )
|
|
||||||
h += 360;
|
|
||||||
#else
|
|
||||||
/* We have to get the right quadrant!
|
/* We have to get the right quadrant!
|
||||||
*/
|
*/
|
||||||
if( a == 0 ) {
|
if( a == 0 ) {
|
||||||
@ -89,7 +84,6 @@ vips_col_ab2h( double a, double b )
|
|||||||
else
|
else
|
||||||
h = VIPS_DEG( t + VIPS_PI );
|
h = VIPS_DEG( t + VIPS_PI );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return( h );
|
return( h );
|
||||||
}
|
}
|
||||||
@ -97,13 +91,7 @@ vips_col_ab2h( double a, double b )
|
|||||||
void
|
void
|
||||||
vips_col_ab2Ch( float a, float b, float *C, float *h )
|
vips_col_ab2Ch( float a, float b, float *C, float *h )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ATAN2
|
|
||||||
*h = VIPS_DEG( atan2( b, a ) );
|
|
||||||
if( *h < 0.0 )
|
|
||||||
*h += 360;
|
|
||||||
#else
|
|
||||||
*h = vips_col_ab2h( a, b );
|
*h = vips_col_ab2h( a, b );
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_HYPOT
|
#ifdef HAVE_HYPOT
|
||||||
*C = hypot( a, b );
|
*C = hypot( a, b );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user