- edited description
Decode function for big endian
Issue #13
closed
unsigned int srcBit = startBit;
unsigned int dstBit = bitSize - 1;
for (unsigned int i = 0; i < bitSize; ++i) {
/* copy bit */
if (data[srcBit / 8] & (1 << (srcBit % 8))) {
retVal |= (1ULL << dstBit);
}
/* next position */
if ((srcBit % 8) == 0) {
srcBit += 15;
} else {
--srcBit;
}
--dstBit;
}
Does not follow this schema: https://doc.micrium.com/download/attachments/15707574/Frame%20Layout%20big%20endian%20format.png?version=1&modificationDate=1413400833000&api=v2
This should be correct:
unsigned int srcBit = startBit;
unsigned int dstBit = 0;
for (unsigned int i = 0; i < bitSize; ++i)
{
if (data[srcBit / 8] & (1 << (srcBit % 8)))
{
retVal |= (1ULL << dstBit);
}
if ((srcBit % 8) == 7)
{
srcBit -= 15;
}
else
{
++srcBit;
}
++dstBit;
}
My propasal in #10 also should have fixed this issue.
Comments (6)
-
reporter -
reporter - edited description
-
reporter - edited description
-
reporter - changed title to Decode function for big endian
-
reporter - changed status to resolved
Sorry, but I guess I totally missunderstood the meaning of startBit. So this is no issue.
-
reporter - changed status to closed
- Log in to comment