mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-23 20:11:01 +00:00
Begin counting the bits from the beginning of the byte stream. The way I was doing it before was silly...
This commit is contained in:
parent
f280c2bb33
commit
ad17404bf7
|
@ -73,7 +73,7 @@ namespace PVRTCC {
|
||||||
const uint8 opaqueBitDepths[4] = { 0, 5, 5, 5 };
|
const uint8 opaqueBitDepths[4] = { 0, 5, 5, 5 };
|
||||||
const uint8 transBitDepths[4] = { 3, 4, 4, 4 };
|
const uint8 transBitDepths[4] = { 3, 4, 4, 4 };
|
||||||
|
|
||||||
m_ColorA = Pixel(m_ByteData, isOpaque? opaqueBitDepths : transBitDepths);
|
m_ColorA = Pixel(m_ByteData, isOpaque? opaqueBitDepths : transBitDepths, 1);
|
||||||
m_ColorACached = true;
|
m_ColorACached = true;
|
||||||
return m_ColorA;
|
return m_ColorA;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,18 +73,14 @@ namespace PVRTCC {
|
||||||
nBits += m_BitDepth[i];
|
nBits += m_BitDepth[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32 nBytes = (nBits >> 3) + ((nBits & 0x7) > 0);
|
int32 byteIdx = 0;
|
||||||
assert(nBytes > 0);
|
|
||||||
|
|
||||||
int32 byteIdx = nBytes - 1;
|
|
||||||
uint32 bitIdx = bitOffset;
|
uint32 bitIdx = bitOffset;
|
||||||
while(bitIdx >= 8) {
|
while(bitIdx >= 8) {
|
||||||
bitIdx -= 8;
|
bitIdx -= 8;
|
||||||
byteIdx--;
|
byteIdx++;
|
||||||
assert(byteIdx >= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int32 i = 3; i >= 0; i--) {
|
for(int32 i = 0; i < 4; i++) {
|
||||||
uint8 &channel = m_Component[i];
|
uint8 &channel = m_Component[i];
|
||||||
uint32 depth = m_BitDepth[i];
|
uint32 depth = m_BitDepth[i];
|
||||||
|
|
||||||
|
@ -94,17 +90,18 @@ namespace PVRTCC {
|
||||||
if(0 == depth) {
|
if(0 == depth) {
|
||||||
channel = 0xFF;
|
channel = 0xFF;
|
||||||
} else if(depth + bitIdx < 8) {
|
} else if(depth + bitIdx < 8) {
|
||||||
channel = (bits[byteIdx] >> bitIdx) & ((1 << depth) - 1);
|
|
||||||
bitIdx += depth;
|
bitIdx += depth;
|
||||||
|
channel = (bits[byteIdx] >> (8 - bitIdx)) & ((1 << depth) - 1);
|
||||||
} else {
|
} else {
|
||||||
const uint32 numLowBits = 8 - bitIdx;
|
const uint32 numLowBits = 8 - bitIdx;
|
||||||
uint32 bitsLeft = depth - numLowBits;
|
uint32 bitsLeft = depth - numLowBits;
|
||||||
channel |= (bits[byteIdx] >> bitIdx) & ((1 << numLowBits) - 1);
|
channel |= bits[byteIdx] & ((1 << numLowBits) - 1);
|
||||||
byteIdx--;
|
byteIdx++;
|
||||||
assert(byteIdx >= 0 || (i == 0 && bitsLeft == 0));
|
|
||||||
|
|
||||||
uint8 highBits = bits[byteIdx] & ((1 << bitsLeft) - 1);
|
const uint8 highBitsMask = ((1 << bitsLeft) - 1);
|
||||||
channel |= highBits << numLowBits;
|
const uint8 highBits = (bits[byteIdx] >> (8 - bitsLeft)) & highBitsMask;
|
||||||
|
channel <<= bitsLeft;
|
||||||
|
channel |= highBits;
|
||||||
bitIdx = bitsLeft;
|
bitIdx = bitsLeft;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue