Actually clamp the initial value

This commit is contained in:
Pavel Krajcevski 2014-04-09 13:55:27 -04:00
parent ea1c61913a
commit 127c825337

View file

@ -295,7 +295,7 @@ double RGBACluster::QuantizedError(
const float pct = ((pt - uqp1) * uqpdir) / uqplsq; const float pct = ((pt - uqp1) * uqpdir) / uqplsq;
int32 j1 = floor(pct * static_cast<float>(nBuckets-1)); int32 j1 = floor(pct * static_cast<float>(nBuckets-1));
int32 j2 = ceil(pct * static_cast<float>(nBuckets-1)); int32 j2 = ceil(pct * static_cast<float>(nBuckets-1));
j1 = std::max(0, j1); j1 = std::min(std::max(0, j1), nBuckets - 1);
j2 = std::min(j2, nBuckets - 1); j2 = std::min(j2, nBuckets - 1);
#endif #endif