|
|
|
@ -265,19 +265,19 @@ class Dither
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::uniform_real_distribution<float> distribution;
|
|
|
|
std::uniform_real_distribution<float> distribution;
|
|
|
|
std::mt19937 gen;
|
|
|
|
std::mt19937 gen;
|
|
|
|
float prev{ 0.0f };
|
|
|
|
float previous;
|
|
|
|
DitherType d;
|
|
|
|
DitherType d;
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
Dither(DitherType d) : distribution(-0.5f, +0.5f), d(d) {}
|
|
|
|
Dither(DitherType d) : distribution(-0.5f, +0.5f), d(d), previous(0.f) {}
|
|
|
|
|
|
|
|
|
|
|
|
float operator()(float s)
|
|
|
|
float operator()(float s)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (d == DITHER_TRIANGLE)
|
|
|
|
if (d == DITHER_TRIANGLE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const float value = distribution(gen);
|
|
|
|
const float value = distribution(gen);
|
|
|
|
s = s + value - prev;
|
|
|
|
s = s + value - previous;
|
|
|
|
prev = value;
|
|
|
|
previous = value;
|
|
|
|
return s;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else return s;
|
|
|
|
else return s;
|
|
|
|
|