Thanks a lot!...
Code: Select all
http://www.mediafire.com/?d60yscryh2uq4hk
Code: Select all
http://www.mediafire.com/?d60yscryh2uq4hk
Code: Select all
private static void decompressFile(String path, BinaryReader br) throws Exception {
int fileSize = br.readInt(); //decompressed filesize
byte[] dFile = new byte[fileSize];
int dIndex = 0;
int bufferSize = 0;
int[][] dTable = new int[256][2];
br.readInt(); //BPE
while ((bufferSize = br.readInt()) != 0) {
int code = 0;
for (int i = 0; i < dTable.length; i++) {
dTable[i][0] = i;
}
/* Table creation phase */
while (code < 256) {
int copyAmount = br.readByte();
if (copyAmount >= 128) {
code = code - 127 + copyAmount;
copyAmount = 0; // i.e. 1 byte
}
if (code < 256) {
for (int i = 0; i <= copyAmount; i++) {
int b = br.readByte();
dTable[ code][0] = b;
if (b != code) {
b = br.readByte();
dTable[ code][1] = b;
}
code++;
}
}
}
/* File decompression phase */
for (int i = 0; i < bufferSize;) {
int input = br.readByte();
Stack<Integer> unresolved = new Stack<Integer>();
unresolved.push(input);
while (!unresolved.empty()) {
int in = unresolved.pop();
if (in != dTable[in][0]) {
unresolved.push(dTable[in][1]);
unresolved.push(dTable[in][0]);
} else {
dFile[dIndex + (i++)] = (byte)in;
}
}
}
dIndex += bufferSize;
if (br.getOffset() % 4 != 0) br.skip(4 - br.getOffset() % 4);
}
new FileOutputStream(path).write(dFile);
}
Code: Select all
if (b != code) {
b = br.readByte();
dTable[ code][1] = b;
}
Code: Select all
if (br.getOffset() % 4 != 0) br.skip(4 - br.getOffset() % 4);