From 4de5f90edfaeb97a0912d936045bdd3250cd2e35 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Wed, 25 Sep 2013 20:10:18 -0400 Subject: [PATCH] Some small bug fixes to our still awful compressor. --- PVRTCEncoder/src/Compressor.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/PVRTCEncoder/src/Compressor.cpp b/PVRTCEncoder/src/Compressor.cpp index 2b167a6..19e1e0f 100644 --- a/PVRTCEncoder/src/Compressor.cpp +++ b/PVRTCEncoder/src/Compressor.cpp @@ -267,7 +267,7 @@ namespace PVRTCC { const Pixel po = original(i, j); // !FIXME! there are two modulation modes... we're only using one. - uint8 modSteps[4] = { 0, 3, 5, 8 }; + uint8 modSteps[4] = { 8, 5, 3, 0 }; uint8 bestMod = 0; uint32 bestError = 0xFFFFFFFF; for(uint32 s = 0; s < 4; s++) { @@ -297,16 +297,19 @@ namespace PVRTCC { const uint32 blocksW = dcj.width / 4; const uint32 blocksH = dcj.height / 4; + assert(imgA.GetHeight() == blocksH); + assert(imgA.GetWidth() == blocksW); + std::vector blocks; blocks.reserve(blocksW * blocksH); for(uint32 j = 0; j < blocksH; j++) { for(uint32 i = 0; i < blocksW; i++) { Block b; - b.SetColorA(imgA(i, j)); - b.SetColorB(imgB(i, j)); + b.SetColorA(imgA(i, j), true); + b.SetColorB(imgB(i, j), true); for(uint32 t = 0; t < 16; t++) { - uint32 x = i + (t%4); - uint32 y = j + (t/4); + uint32 x = i*4 + (t%4); + uint32 y = j*4 + (t/4); b.SetLerpValue(t, modValues[y*dcj.width + x]); } blocks.push_back(b.Pack()); @@ -321,9 +324,8 @@ namespace PVRTCC { // linearize them... uint32 idx = Interleave(j, i); - uint32 offset = idx * PVRTCC::kBlockSize; - uint64 *outPtr = reinterpret_cast(dcj.outBuf + offset); - *outPtr = blocks[j * blocksW + i]; + uint64 *outPtr = reinterpret_cast(dcj.outBuf); + outPtr[idx] = blocks[j*blocksW + i]; } } }