Formatting.

This commit is contained in:
Pavel Krajcevski 2014-03-25 18:27:26 -04:00
parent 6505944f57
commit 7fa561f67f
2 changed files with 12 additions and 16 deletions

View file

@ -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,7 +261,7 @@ 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<uint8>(pb[k], ip);
errorVec[k] = static_cast<float>(dist) * metric[k];

View file

@ -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<const uint8 nBuckets>
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<const uint8 nBuckets>
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);