From 7fa561f67fa269e77c57c241904acc341088358d Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Tue, 25 Mar 2014 18:27:26 -0400 Subject: [PATCH] Formatting. --- BPTCEncoder/src/RGBAEndpoints.cpp | 16 ++++++---------- BPTCEncoder/src/RGBAEndpoints.h | 12 ++++++------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/BPTCEncoder/src/RGBAEndpoints.cpp b/BPTCEncoder/src/RGBAEndpoints.cpp index bc8efb5..a2d5bef 100755 --- a/BPTCEncoder/src/RGBAEndpoints.cpp +++ b/BPTCEncoder/src/RGBAEndpoints.cpp @@ -225,23 +225,19 @@ double RGBACluster::QuantizedError( ) const { // nBuckets should be a power of two. + const uint8 indexPrec = log2(nBuckets); assert(!(nBuckets & (nBuckets - 1))); - const uint8 indexPrec = 8-CountBitsInMask(~(nBuckets - 1)); + assert(indexPrec >= 2 && indexPrec <= 4); typedef uint32 tInterpPair[2]; typedef tInterpPair tInterpLevel[16]; - const tInterpLevel *interpVals = - (nBuckets == 3)? BPTCC::kInterpolationValues - : BPTCC::kInterpolationValues + (indexPrec - 1); - - assert(indexPrec >= 2 && indexPrec <= 4); + const tInterpLevel *interpVals = BPTCC::kInterpolationValues + (indexPrec - 1); uint32 qp1, qp2; if(pbits) { qp1 = p1.ToPixel(bitMask, pbits[0]); qp2 = p2.ToPixel(bitMask, pbits[1]); - } - else { + } else { qp1 = p1.ToPixel(bitMask); qp2 = p2.ToPixel(bitMask); } @@ -265,12 +261,12 @@ double RGBACluster::QuantizedError( uint32 interp1 = (*interpVals)[j][1]; RGBAVector errorVec (0.0f); - for(uint32 k = 0; k < kNumColorChannels; k++) { + for(uint32 k = 0; k < 4; k++) { const uint32 ip = (((pqp1[k] * interp0) + (pqp2[k] * interp1) + 32) >> 6) & 0xFF; const uint8 dist = sad(pb[k], ip); errorVec[k] = static_cast(dist) * metric[k]; } - + float error = errorVec * errorVec; if(error < minError) { minError = error; diff --git a/BPTCEncoder/src/RGBAEndpoints.h b/BPTCEncoder/src/RGBAEndpoints.h index da07186..786b6a7 100755 --- a/BPTCEncoder/src/RGBAEndpoints.h +++ b/BPTCEncoder/src/RGBAEndpoints.h @@ -170,12 +170,6 @@ public: // Returns the error if we were to quantize the colors right now with the // given number of buckets and bit mask. - template - double QuantizedError( - const RGBAVector &p1, const RGBAVector &p2, - uint32 bitMask, const RGBAVector &errorMetricVec, - const int pbits[2] = NULL, uint8 *indices = NULL) const; - double QuantizedError( const RGBAVector &p1, const RGBAVector &p2, uint32 nBuckets, uint32 bitMask, const RGBAVector &errorMetricVec, @@ -228,6 +222,12 @@ public: uint8 m_PointMap[kMaxNumDataPoints]; RGBAVector m_Min, m_Max; + template + double QuantizedError( + const RGBAVector &p1, const RGBAVector &p2, + uint32 bitMask, const RGBAVector &errorMetricVec, + const int pbits[2] = NULL, uint8 *indices = NULL) const; + void Recalculate() { m_NumPoints = 0; m_Avg = RGBAVector(0.0f);