From 127c825337ec0064e9dafd8ae8b4bc53419268d7 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Wed, 9 Apr 2014 13:55:27 -0400 Subject: [PATCH] Actually clamp the initial value --- BPTCEncoder/src/RGBAEndpoints.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BPTCEncoder/src/RGBAEndpoints.cpp b/BPTCEncoder/src/RGBAEndpoints.cpp index 5a11ea0..f5aa349 100755 --- a/BPTCEncoder/src/RGBAEndpoints.cpp +++ b/BPTCEncoder/src/RGBAEndpoints.cpp @@ -295,7 +295,7 @@ double RGBACluster::QuantizedError( const float pct = ((pt - uqp1) * uqpdir) / uqplsq; int32 j1 = floor(pct * static_cast(nBuckets-1)); int32 j2 = ceil(pct * static_cast(nBuckets-1)); - j1 = std::max(0, j1); + j1 = std::min(std::max(0, j1), nBuckets - 1); j2 = std::min(j2, nBuckets - 1); #endif