JANITORIAL: Whitespace fixes

This commit is contained in:
Eugene Sandulenko 2018-05-05 14:01:56 +02:00
parent c234630931
commit e3b9be6679

View File

@ -27,145 +27,145 @@
namespace Prince {
static const uint16 table1[] = {
0x8000, 0x0002,
0x4000, 0x0004,
0x2000, 0x0008,
0x1000, 0x0010,
0x0800, 0x0020,
0x0400, 0x0040,
0x0200, 0x0080,
0x0100, 0x0100,
0x0080, 0x0200,
0x0040, 0x0400
0x8000, 0x0002,
0x4000, 0x0004,
0x2000, 0x0008,
0x1000, 0x0010,
0x0800, 0x0020,
0x0400, 0x0040,
0x0200, 0x0080,
0x0100, 0x0100,
0x0080, 0x0200,
0x0040, 0x0400
};
static const uint32 table2[] = {
0x0000F000,
0x0020FC00,
0x00A0FF00,
0x02A0FF80,
0x06A0FFC0,
0x0EA0FFE0,
0x1EA0FFF0,
0x3EA0FFF8
0x0000F000,
0x0020FC00,
0x00A0FF00,
0x02A0FF80,
0x06A0FFC0,
0x0EA0FFE0,
0x1EA0FFF0,
0x3EA0FFF8
};
static const uint16 table3[] = {
0x8000, 0x0000,
0x4000, 0x0002,
0x2000, 0x0006,
0x1000, 0x000E,
0x0800, 0x001E,
0x0400, 0x003E,
0x0200, 0x007E,
0x0100, 0x00FE,
0x0080, 0x01FE,
0x0040, 0x03FE,
0x0020, 0x07FE,
0x0010, 0x0FFE,
0x0008, 0x1FFE,
0x0004, 0x3FFE,
0x0002, 0x7FFE,
0x0001, 0xFFFE
0x8000, 0x0000,
0x4000, 0x0002,
0x2000, 0x0006,
0x1000, 0x000E,
0x0800, 0x001E,
0x0400, 0x003E,
0x0200, 0x007E,
0x0100, 0x00FE,
0x0080, 0x01FE,
0x0040, 0x03FE,
0x0020, 0x07FE,
0x0010, 0x0FFE,
0x0008, 0x1FFE,
0x0004, 0x3FFE,
0x0002, 0x7FFE,
0x0001, 0xFFFE
};
void Decompressor::decompress(byte *source, byte *dest, uint32 destSize) {
byte *destEnd = dest + destSize;
int more;
_src = source;
_dst = dest;
_bitBuffer = 0x80;
while (_dst < destEnd) {
uint32 ebp;
uint16 offset, length;
if (getBit()) {
if (getBit()) {
if (getBit()) {
if (getBit()) {
if (getBit()) {
if (getBit()) {
uint32 tableIndex = 0;
while (getBit())
tableIndex++;
length = table3[tableIndex * 2 + 0];
do {
more = !(length & 0x8000);
length = (length << 1) | getBit();
} while (more);
length += table3[tableIndex * 2 + 1];
length++;
memcpy(_dst, _src, length);
_src += length;
_dst += length;
}
*_dst++ = *_src++;
}
*_dst++ = *_src++;
}
*_dst++ = *_src++;
}
*_dst++ = *_src++;
}
*_dst++ = *_src++;
}
if (!getBit()) {
if (getBit()) {
uint32 tableIndex = getBit();
tableIndex = (tableIndex << 1) | getBit();
tableIndex = (tableIndex << 1) | getBit();
ebp = table2[tableIndex];
length = 1;
} else {
ebp = 0x0000FF00;
length = 0;
}
} else {
uint32 tableIndex = 0;
while (getBit())
tableIndex++;
length = table1[tableIndex * 2 + 0];
do {
more = !(length & 0x8000);
length = (length << 1) | getBit();
} while (more);
length += table1[tableIndex * 2 + 1];
tableIndex = getBit();
tableIndex = (tableIndex << 1) | getBit();
tableIndex = (tableIndex << 1) | getBit();
ebp = table2[tableIndex];
}
offset = ebp & 0xFFFF;
do {
if (_bitBuffer == 0x80) {
if (offset >= 0xFF00) {
offset = (offset << 8) | *_src++;
}
}
more = offset & 0x8000;
offset = (offset << 1) | getBit();
} while (more);
offset += (ebp >> 16);
length += 2;
while (length--) {
if (_dst >= destEnd) {
return;
}
*_dst = *(_dst - offset);
_dst++;
}
}
byte *destEnd = dest + destSize;
int more;
_src = source;
_dst = dest;
_bitBuffer = 0x80;
while (_dst < destEnd) {
uint32 ebp;
uint16 offset, length;
if (getBit()) {
if (getBit()) {
if (getBit()) {
if (getBit()) {
if (getBit()) {
if (getBit()) {
uint32 tableIndex = 0;
while (getBit())
tableIndex++;
length = table3[tableIndex * 2 + 0];
do {
more = !(length & 0x8000);
length = (length << 1) | getBit();
} while (more);
length += table3[tableIndex * 2 + 1];
length++;
memcpy(_dst, _src, length);
_src += length;
_dst += length;
}
*_dst++ = *_src++;
}
*_dst++ = *_src++;
}
*_dst++ = *_src++;
}
*_dst++ = *_src++;
}
*_dst++ = *_src++;
}
if (!getBit()) {
if (getBit()) {
uint32 tableIndex = getBit();
tableIndex = (tableIndex << 1) | getBit();
tableIndex = (tableIndex << 1) | getBit();
ebp = table2[tableIndex];
length = 1;
} else {
ebp = 0x0000FF00;
length = 0;
}
} else {
uint32 tableIndex = 0;
while (getBit())
tableIndex++;
length = table1[tableIndex * 2 + 0];
do {
more = !(length & 0x8000);
length = (length << 1) | getBit();
} while (more);
length += table1[tableIndex * 2 + 1];
tableIndex = getBit();
tableIndex = (tableIndex << 1) | getBit();
tableIndex = (tableIndex << 1) | getBit();
ebp = table2[tableIndex];
}
offset = ebp & 0xFFFF;
do {
if (_bitBuffer == 0x80) {
if (offset >= 0xFF00) {
offset = (offset << 8) | *_src++;
}
}
more = offset & 0x8000;
offset = (offset << 1) | getBit();
} while (more);
offset += (ebp >> 16);
length += 2;
while (length--) {
if (_dst >= destEnd) {
return;
}
*_dst = *(_dst - offset);
_dst++;
}
}
}
int Decompressor::getBit() {
int bit = (_bitBuffer & 0x80) >> 7;
_bitBuffer <<= 1;
if (_bitBuffer == 0) {
_bitBuffer = *_src++;
bit = (_bitBuffer & 0x80) >> 7;
_bitBuffer <<= 1;
_bitBuffer |= 1;
}
return bit;
int bit = (_bitBuffer & 0x80) >> 7;
_bitBuffer <<= 1;
if (_bitBuffer == 0) {
_bitBuffer = *_src++;
bit = (_bitBuffer & 0x80) >> 7;
_bitBuffer <<= 1;
_bitBuffer |= 1;
}
return bit;
}
} // End of namespace Prince