Renamed part of HuffmanCodec

This commit is contained in:
Pazaz 2022-06-28 00:33:40 -04:00
parent a941543566
commit 8aaa00efd5
4 changed files with 79 additions and 81 deletions

View file

@ -41,6 +41,9 @@ public class Buffer extends Node {
@OriginalMember(owner = "client!dc", name = "db", descriptor = "[[B")
public static final byte[][] allocatedMax = new byte[50][];
@OriginalMember(owner = "client!fi", name = "c", descriptor = "[I")
public static final int[] CRC32_TABLE = new int[256];
@OriginalMember(owner = "client!qj", name = "a", descriptor = "[J")
public static final long[] CRC64_TABLE = new long[256];
@ -60,6 +63,18 @@ public class Buffer extends Node {
public int offset;
static {
for (@Pc(4) int i = 0; i < 256; i++) {
@Pc(9) int temp = i;
for (@Pc(11) int j = 0; j < 8; j++) {
if ((temp & 0x1) == 1) {
temp = temp >>> 1 ^ 0xEDB88320;
} else {
temp >>>= 0x1;
}
}
CRC32_TABLE[i] = temp;
}
for (@Pc(4) int local4 = 0; local4 < 256; local4++) {
@Pc(10) long local10 = local4;
for (@Pc(12) int local12 = 0; local12 < 8; local12++) {
@ -110,7 +125,7 @@ public class Buffer extends Node {
public static int crc32(@OriginalArg(0) int offset, @OriginalArg(1) int size, @OriginalArg(2) byte[] src) {
@Pc(5) int crc = -1;
for (@Pc(15) int i = offset; i < size; i++) {
crc = crc >>> 8 ^ HuffmanCodec.crctable[(crc ^ src[i]) & 0xFF];
crc = crc >>> 8 ^ CRC32_TABLE[(crc ^ src[i]) & 0xFF];
}
return ~crc;
}

View file

@ -8,109 +8,92 @@ import org.openrs2.deob.annotation.Pc;
@OriginalClass("client!fi")
public final class HuffmanCodec {
@OriginalMember(owner = "client!fi", name = "c", descriptor = "[I")
public static final int[] crctable = new int[256];
@OriginalMember(owner = "client!fi", name = "b", descriptor = "[I")
private int[] anIntArray174;
private int[] symbolTree;
@OriginalMember(owner = "client!fi", name = "h", descriptor = "[I")
private final int[] anIntArray176;
private final int[] codewords;
@OriginalMember(owner = "client!fi", name = "e", descriptor = "[B")
private final byte[] aByteArray22;
static {
for (@Pc(4) int i = 0; i < 256; i++) {
@Pc(9) int temp = i;
for (@Pc(11) int j = 0; j < 8; j++) {
if ((temp & 0x1) == 1) {
temp = temp >>> 1 ^ 0xEDB88320;
} else {
temp >>>= 0x1;
}
}
crctable[i] = temp;
}
}
private final byte[] bits;
@OriginalMember(owner = "client!fi", name = "<init>", descriptor = "([B)V")
public HuffmanCodec(@OriginalArg(0) byte[] arg0) {
@Pc(6) int[] local6 = new int[33];
@Pc(9) int local9 = arg0.length;
this.anIntArray174 = new int[8];
this.anIntArray176 = new int[local9];
this.aByteArray22 = arg0;
@Pc(22) int local22 = 0;
for (@Pc(24) int local24 = 0; local24 < local9; local24++) {
@Pc(35) byte local35 = arg0[local24];
if (local35 != 0) {
@Pc(49) int local49 = 0x1 << 32 - local35;
@Pc(53) int local53 = local6[local35];
this.anIntArray176[local24] = local53;
public HuffmanCodec(@OriginalArg(0) byte[] bits) {
@Pc(6) int[] nextCodewords = new int[33];
@Pc(9) int symbols = bits.length;
this.symbolTree = new int[8];
this.codewords = new int[symbols];
this.bits = bits;
@Pc(22) int nextNode = 0;
for (@Pc(24) int symbol = 0; symbol < symbols; symbol++) {
@Pc(35) byte codewordBits = bits[symbol];
if (codewordBits != 0) {
@Pc(49) int bit = 0x1 << 32 - codewordBits;
@Pc(53) int codeword = nextCodewords[codewordBits];
this.codewords[symbol] = codeword;
@Pc(121) int local121;
@Pc(67) int local67;
@Pc(76) int local76;
@Pc(92) int local92;
if ((local53 & local49) == 0) {
for (local67 = local35 - 1; local67 >= 1; local67--) {
local76 = local6[local67];
if (local53 != local76) {
if ((codeword & bit) == 0) {
for (local67 = codewordBits - 1; local67 >= 1; local67--) {
local76 = nextCodewords[local67];
if (codeword != local76) {
break;
}
local92 = 0x1 << 32 - local67;
if ((local76 & local92) != 0) {
local6[local67] = local6[local67 - 1];
nextCodewords[local67] = nextCodewords[local67 - 1];
break;
}
local6[local67] = local92 | local76;
nextCodewords[local67] = local92 | local76;
}
local121 = local53 | local49;
local121 = codeword | bit;
} else {
local121 = local6[local35 - 1];
local121 = nextCodewords[codewordBits - 1];
}
local6[local35] = local121;
for (local67 = local35 + 1; local67 <= 32; local67++) {
if (local53 == local6[local67]) {
local6[local67] = local121;
nextCodewords[codewordBits] = local121;
for (local67 = codewordBits + 1; local67 <= 32; local67++) {
if (codeword == nextCodewords[local67]) {
nextCodewords[local67] = local121;
}
}
local67 = 0;
for (local76 = 0; local76 < local35; local76++) {
for (local76 = 0; local76 < codewordBits; local76++) {
local92 = Integer.MIN_VALUE >>> local76;
if ((local53 & local92) == 0) {
if ((codeword & local92) == 0) {
local67++;
} else {
if (this.anIntArray174[local67] == 0) {
this.anIntArray174[local67] = local22;
if (this.symbolTree[local67] == 0) {
this.symbolTree[local67] = nextNode;
}
local67 = this.anIntArray174[local67];
local67 = this.symbolTree[local67];
}
if (this.anIntArray174.length <= local67) {
@Pc(206) int[] local206 = new int[this.anIntArray174.length * 2];
for (@Pc(208) int local208 = 0; local208 < this.anIntArray174.length; local208++) {
local206[local208] = this.anIntArray174[local208];
if (this.symbolTree.length <= local67) {
@Pc(206) int[] local206 = new int[this.symbolTree.length * 2];
for (@Pc(208) int local208 = 0; local208 < this.symbolTree.length; local208++) {
local206[local208] = this.symbolTree[local208];
}
this.anIntArray174 = local206;
this.symbolTree = local206;
}
}
this.anIntArray174[local67] = ~local24;
if (local67 >= local22) {
local22 = local67 + 1;
this.symbolTree[local67] = ~symbol;
if (local67 >= nextNode) {
nextNode = local67 + 1;
}
}
}
}
@OriginalMember(owner = "client!fi", name = "a", descriptor = "(II[B[BII)I")
public final int method1550(@OriginalArg(0) int arg0, @OriginalArg(2) byte[] arg1, @OriginalArg(3) byte[] arg2, @OriginalArg(4) int arg3, @OriginalArg(5) int arg4) {
public final int encode(@OriginalArg(0) int arg0, @OriginalArg(2) byte[] arg1, @OriginalArg(3) byte[] arg2, @OriginalArg(4) int arg3, @OriginalArg(5) int arg4) {
@Pc(5) int local5 = arg0;
@Pc(11) int local11 = 0;
@Pc(15) int local15 = arg4 << 3;
while (local5 > arg3) {
@Pc(24) int local24 = arg2[arg3] & 0xFF;
@Pc(29) int local29 = this.anIntArray176[local24];
@Pc(34) byte local34 = this.aByteArray22[local24];
@Pc(29) int local29 = this.codewords[local24];
@Pc(34) byte local34 = this.bits[local24];
if (local34 == 0) {
throw new RuntimeException("No codeword for data value " + local24);
}
@ -147,7 +130,7 @@ public final class HuffmanCodec {
}
@OriginalMember(owner = "client!fi", name = "a", descriptor = "(II[BI[BI)I")
public final int method1552(@OriginalArg(0) int arg0, @OriginalArg(1) int arg1, @OriginalArg(2) byte[] arg2, @OriginalArg(4) byte[] arg3, @OriginalArg(5) int arg4) {
public final int decode(@OriginalArg(0) int arg0, @OriginalArg(1) int arg1, @OriginalArg(2) byte[] arg2, @OriginalArg(4) byte[] arg3, @OriginalArg(5) int arg4) {
if (arg1 == 0) {
return 0;
}
@ -157,12 +140,12 @@ public final class HuffmanCodec {
while (true) {
@Pc(25) byte local25 = arg3[local21];
if (local25 < 0) {
local15 = this.anIntArray174[local15];
local15 = this.symbolTree[local15];
} else {
local15++;
}
@Pc(41) int local41;
if ((local41 = this.anIntArray174[local15]) < 0) {
if ((local41 = this.symbolTree[local15]) < 0) {
arg2[arg0++] = (byte) ~local41;
if (arg0 >= local19) {
break;
@ -172,10 +155,10 @@ public final class HuffmanCodec {
if ((local25 & 0x40) == 0) {
local15++;
} else {
local15 = this.anIntArray174[local15];
local15 = this.symbolTree[local15];
}
@Pc(78) int local78;
if ((local78 = this.anIntArray174[local15]) < 0) {
if ((local78 = this.symbolTree[local15]) < 0) {
arg2[arg0++] = (byte) ~local78;
if (local19 <= arg0) {
break;
@ -185,10 +168,10 @@ public final class HuffmanCodec {
if ((local25 & 0x20) == 0) {
local15++;
} else {
local15 = this.anIntArray174[local15];
local15 = this.symbolTree[local15];
}
@Pc(118) int local118;
if ((local118 = this.anIntArray174[local15]) < 0) {
if ((local118 = this.symbolTree[local15]) < 0) {
arg2[arg0++] = (byte) ~local118;
if (local19 <= arg0) {
break;
@ -198,10 +181,10 @@ public final class HuffmanCodec {
if ((local25 & 0x10) == 0) {
local15++;
} else {
local15 = this.anIntArray174[local15];
local15 = this.symbolTree[local15];
}
@Pc(156) int local156;
if ((local156 = this.anIntArray174[local15]) < 0) {
if ((local156 = this.symbolTree[local15]) < 0) {
arg2[arg0++] = (byte) ~local156;
if (arg0 >= local19) {
break;
@ -211,10 +194,10 @@ public final class HuffmanCodec {
if ((local25 & 0x8) == 0) {
local15++;
} else {
local15 = this.anIntArray174[local15];
local15 = this.symbolTree[local15];
}
@Pc(195) int local195;
if ((local195 = this.anIntArray174[local15]) < 0) {
if ((local195 = this.symbolTree[local15]) < 0) {
arg2[arg0++] = (byte) ~local195;
if (local19 <= arg0) {
break;
@ -224,10 +207,10 @@ public final class HuffmanCodec {
if ((local25 & 0x4) == 0) {
local15++;
} else {
local15 = this.anIntArray174[local15];
local15 = this.symbolTree[local15];
}
@Pc(233) int local233;
if ((local233 = this.anIntArray174[local15]) < 0) {
if ((local233 = this.symbolTree[local15]) < 0) {
arg2[arg0++] = (byte) ~local233;
if (arg0 >= local19) {
break;
@ -237,10 +220,10 @@ public final class HuffmanCodec {
if ((local25 & 0x2) == 0) {
local15++;
} else {
local15 = this.anIntArray174[local15];
local15 = this.symbolTree[local15];
}
@Pc(276) int local276;
if ((local276 = this.anIntArray174[local15]) < 0) {
if ((local276 = this.symbolTree[local15]) < 0) {
arg2[arg0++] = (byte) ~local276;
if (arg0 >= local19) {
break;
@ -250,10 +233,10 @@ public final class HuffmanCodec {
if ((local25 & 0x1) == 0) {
local15++;
} else {
local15 = this.anIntArray174[local15];
local15 = this.symbolTree[local15];
}
@Pc(318) int local318;
if ((local318 = this.anIntArray174[local15]) < 0) {
if ((local318 = this.symbolTree[local15]) < 0) {
arg2[arg0++] = (byte) ~local318;
if (arg0 >= local19) {
break;

View file

@ -3307,7 +3307,7 @@ public class Protocol {
local7 = 32767;
}
@Pc(15) byte[] local15 = new byte[local7];
arg0.offset += WordPack.codec.method1552(0, local7, local15, arg0.data, arg0.offset);
arg0.offset += WordPack.codec.decode(0, local7, local15, arg0.data, arg0.offset);
return JagString.decodeString(local15, local7, 0);
} catch (@Pc(47) Exception local47) {
return WordPack.CABBAGE;

View file

@ -20,7 +20,7 @@ public class WordPack {
@Pc(6) int local6 = arg0.offset;
@Pc(14) byte[] local14 = arg1.method3148();
arg0.psmarts(local14.length);
arg0.offset += codec.method1550(local14.length, arg0.data, local14, 0, arg0.offset);
arg0.offset += codec.encode(local14.length, arg0.data, local14, 0, arg0.offset);
return arg0.offset - local6;
}
}