calcBlendFactor(): templated, also a small speedup be reordering instructions
This commit is contained in:
@@ -34,23 +34,14 @@
|
|||||||
#include "sleef.h"
|
#include "sleef.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
float calcBlendFactor(float val, float threshold) {
|
|
||||||
// sigmoid function
|
|
||||||
// result is in ]0;1] range
|
|
||||||
// inflexion point is at (x, y) (threshold, 0.5)
|
|
||||||
return 1.f / (1.f + xexpf(16.f - 16.f * val / threshold));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __SSE2__
|
template<typename T>
|
||||||
vfloat calcBlendFactor(vfloat valv, vfloat thresholdv) {
|
T calcBlendFactor(T val, T threshold) {
|
||||||
// sigmoid function
|
// sigmoid function
|
||||||
// result is in ]0;1] range
|
// result is in ]0;1] range
|
||||||
// inflexion point is at (x, y) (threshold, 0.5)
|
// inflexion point is at (x, y) (threshold, 0.5)
|
||||||
const vfloat onev = F2V(1.f);
|
return 1.f / (1.f + xexpf(16.f - (16.f / threshold) * val));
|
||||||
const vfloat c16v = F2V(16.f);
|
|
||||||
return onev / (onev + xexpf(c16v - c16v * valv / thresholdv));
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
float tileAverage(const float * const *data, size_t tileY, size_t tileX, size_t tilesize) {
|
float tileAverage(const float * const *data, size_t tileY, size_t tileX, size_t tilesize) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user