Minor cleanups
This commit is contained in:
parent
cf0ccc26ca
commit
af4b17ac84
@ -58,6 +58,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@ -98,8 +99,8 @@ protected:
|
|||||||
unsigned int size;
|
unsigned int size;
|
||||||
unsigned int upperBound; // always equals size-1, parameter created for performance reason
|
unsigned int upperBound; // always equals size-1, parameter created for performance reason
|
||||||
private:
|
private:
|
||||||
unsigned int owner;
|
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
|
unsigned int owner;
|
||||||
alignas(16) vfloat maxsv;
|
alignas(16) vfloat maxsv;
|
||||||
alignas(16) vfloat sizev;
|
alignas(16) vfloat sizev;
|
||||||
alignas(16) vint sizeiv;
|
alignas(16) vint sizeiv;
|
||||||
@ -140,35 +141,30 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LUT(const std::vector<T> input, int flags = LUT_CLIP_BELOW | LUT_CLIP_ABOVE)
|
LUT(const std::vector<T>& input, int flags = LUT_CLIP_BELOW | LUT_CLIP_ABOVE) :
|
||||||
|
maxs(input.size() - 2),
|
||||||
|
maxsf(maxs),
|
||||||
|
data(new T[input.size() + 3]), // Add a few extra elements so [](vfloat) won't access out-of-bounds memory.
|
||||||
|
clip(flags),
|
||||||
|
size(input.size()),
|
||||||
|
upperBound(size - 1),
|
||||||
|
owner(1),
|
||||||
|
#ifdef __SSE2__
|
||||||
|
maxsv(F2V(maxs)),
|
||||||
|
sizev(F2V(size - 1)),
|
||||||
|
sizeiv(_mm_set1_epi32(size - 1)),
|
||||||
|
#endif
|
||||||
|
dirty(true)
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
||||||
if (input.size() <= 0) {
|
if (input.empty()) {
|
||||||
printf("s<=0!\n");
|
printf("s=0!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (input.size() > 0);
|
assert(!input.empty());
|
||||||
#endif
|
#endif
|
||||||
dirty = true;
|
std::copy_n(input.begin(), input.size(), data);
|
||||||
clip = flags;
|
|
||||||
// Add a few extra elements so [](vfloat) won't access out-of-bounds memory.
|
|
||||||
// The routine would still produce the right answer, but might cause issues
|
|
||||||
// with address/heap checking programs.
|
|
||||||
data = new T[input.size() + 3];
|
|
||||||
owner = 1;
|
|
||||||
size = input.size();
|
|
||||||
upperBound = size - 1;
|
|
||||||
maxs = size - 2;
|
|
||||||
maxsf = (float)maxs;
|
|
||||||
#ifdef __SSE2__
|
|
||||||
maxsv = F2V( maxs );
|
|
||||||
sizeiv = _mm_set1_epi32( (int)(size - 1) );
|
|
||||||
sizev = F2V( size - 1 );
|
|
||||||
#endif
|
|
||||||
for (size_t i = 0; i < input.size(); ++i) {
|
|
||||||
data[i] = input[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator ()(int s, int flags = LUT_CLIP_BELOW | LUT_CLIP_ABOVE, bool initZero = false)
|
void operator ()(int s, int flags = LUT_CLIP_BELOW | LUT_CLIP_ABOVE, bool initZero = false)
|
||||||
@ -514,19 +510,19 @@ public:
|
|||||||
return (p1 + p2 * diff);
|
return (p1 + p2 * diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool (void) const
|
operator bool() const // FIXME: Should be explicit
|
||||||
{
|
{
|
||||||
return size > 0;
|
return size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear(void)
|
void clear()
|
||||||
{
|
{
|
||||||
if (data && size) {
|
if (data && size) {
|
||||||
memset(data, 0, size * sizeof(T));
|
memset(data, 0, size * sizeof(T));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(void)
|
void reset()
|
||||||
{
|
{
|
||||||
if (data) {
|
if (data) {
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
constexpr int limscope = 80;
|
constexpr int limscope = 80;
|
||||||
constexpr int mSPsharp = 39; //minimum size Spot Sharp due to buildblendmask
|
constexpr int mSPsharp = 39; //minimum size Spot Sharp due to buildblendmask
|
||||||
constexpr int mSPwav = 32; //minimum size Spot Wavelet
|
constexpr int mSPwav = 32; //minimum size Spot Wavelet
|
||||||
@ -68,14 +69,16 @@ constexpr int TS = 64; // Tile size
|
|||||||
constexpr float epsilonw = 0.001f / (TS * TS); //tolerance
|
constexpr float epsilonw = 0.001f / (TS * TS); //tolerance
|
||||||
constexpr int offset = 25; // shift between tiles
|
constexpr int offset = 25; // shift between tiles
|
||||||
|
|
||||||
std::unique_ptr<LUTf> buildMeaLut(const float inVals[11], const float mea[10], float &lutFactor) {
|
std::unique_ptr<LUTf> buildMeaLut(const float inVals[11], const float mea[10], float& lutFactor)
|
||||||
|
{
|
||||||
constexpr int lutSize = 100;
|
constexpr int lutSize = 100;
|
||||||
const float lutMax = ceil(mea[9]);
|
|
||||||
|
const float lutMax = std::ceil(mea[9]);
|
||||||
const float lutDiff = lutMax / lutSize;
|
const float lutDiff = lutMax / lutSize;
|
||||||
|
|
||||||
std::vector<float> lutVals(lutSize);
|
std::vector<float> lutVals(lutSize);
|
||||||
int jStart = 1;
|
int jStart = 1;
|
||||||
for (int i = 0; i < 100; ++i) {
|
for (int i = 0; i < lutSize; ++i) {
|
||||||
const float val = i * lutDiff;
|
const float val = i * lutDiff;
|
||||||
if (val < mea[0]) {
|
if (val < mea[0]) {
|
||||||
// still < first value => no interpolation
|
// still < first value => no interpolation
|
||||||
@ -87,35 +90,38 @@ std::unique_ptr<LUTf> buildMeaLut(const float inVals[11], const float mea[10], f
|
|||||||
lutVals[i] = inVals[j];
|
lutVals[i] = inVals[j];
|
||||||
++jStart;
|
++jStart;
|
||||||
break;
|
break;
|
||||||
} else if (val < mea[j]) {
|
}
|
||||||
|
if (val < mea[j]) {
|
||||||
// interpolate
|
// interpolate
|
||||||
const float dist = (val - mea[j - 1]) / (mea[j] - mea[j - 1]);
|
const float dist = (val - mea[j - 1]) / (mea[j] - mea[j - 1]);
|
||||||
lutVals[i] = rtengine::intp(dist, inVals[j], inVals[j - 1]);
|
lutVals[i] = rtengine::intp(dist, inVals[j], inVals[j - 1]);
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
lutVals[i] = inVals[10];
|
|
||||||
}
|
}
|
||||||
|
lutVals[i] = inVals[10];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lutFactor = 1.f / lutDiff;
|
lutFactor = 1.f / lutDiff;
|
||||||
return std::unique_ptr<LUTf>(new LUTf(lutVals));
|
return std::unique_ptr<LUTf>(new LUTf(lutVals));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr float clipLoc(float x) {
|
constexpr float clipLoc(float x)
|
||||||
|
{
|
||||||
return rtengine::LIM(x, 0.f, 32767.f);
|
return rtengine::LIM(x, 0.f, 32767.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr float clipDE(float x) {
|
constexpr float clipDE(float x)
|
||||||
|
{
|
||||||
return rtengine::LIM(x, 0.3f, 1.f);
|
return rtengine::LIM(x, 0.3f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr float clipC(float x) {
|
constexpr float clipC(float x)
|
||||||
|
{
|
||||||
return rtengine::LIM(x, -42000.f, 42000.f);
|
return rtengine::LIM(x, -42000.f, 42000.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr float clipChro(float x) {
|
constexpr float clipChro(float x)
|
||||||
|
{
|
||||||
return rtengine::LIM(x, 0.f, 140.f);
|
return rtengine::LIM(x, 0.f, 140.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user