linearToLogScale() - Input validation (#3932)

This commit is contained in:
Oskar Wallgren
2017-11-03 09:41:28 +01:00
committed by GitHub
parent f15acb8620
commit 0c31cf49c0

View File

@@ -229,11 +229,12 @@ static inline float logToLinearScale( float min, float max, float value )
static inline float linearToLogScale( float min, float max, float value )
{
static const float EXP = 1.0f / F_E;
const float val = ( value - min ) / ( max - min );
const float valueLimited = qBound( min, value, max);
const float val = ( valueLimited - min ) / ( max - min );
if( min < 0 )
{
const float mmax = qMax( qAbs( min ), qAbs( max ) );
float result = signedPowf( value / mmax, EXP ) * mmax;
float result = signedPowf( valueLimited / mmax, EXP ) * mmax;
return isnan( result ) ? 0 : result;
}
float result = powf( val, EXP ) * ( max - min ) + min;