MCPcopy Create free account
hub / github.com/demoth/jake2 / Huff1TableInit

Method Huff1TableInit

client/src/main/java/jake2/client/SCR.java:1519–1559  ·  view source on GitHub ↗

Huff1TableInit Reads the 64k counts table and initializes the node trees.

()

Source from the content-addressed store, hash-verified

1517 *
1518 */
1519 private static void Huff1TableInit() {
1520 int[] node;
1521 byte[] counts = new byte[256];
1522 int numhnodes;
1523
1524 cin.hnodes1 = new int[256 * 256 * 2];
1525 Arrays.fill(cin.hnodes1, 0);
1526
1527 for (int prev = 0; prev < 256; prev++) {
1528 Arrays.fill(cin.h_count, 0);
1529 Arrays.fill(cin.h_used, 0);
1530
1531 // read a row of counts
1532 ClientGlobals.cl.cinematic_file.get(counts);
1533 for (int j = 0; j < 256; j++)
1534 cin.h_count[j] = counts[j] & 0xFF;
1535
1536 // build the nodes
1537 numhnodes = 256;
1538 int nodebase = 0 + prev * 256 * 2;
1539 int index = 0;
1540 node = cin.hnodes1;
1541 while (numhnodes != 511) {
1542 index = nodebase + (numhnodes - 256) * 2;
1543
1544 // pick two lowest counts
1545 node[index] = SmallestNode1(numhnodes);
1546 if (node[index] == -1)
1547 break; // no more
1548
1549 node[index + 1] = SmallestNode1(numhnodes);
1550 if (node[index + 1] == -1)
1551 break;
1552
1553 cin.h_count[numhnodes] = cin.h_count[node[index]] + cin.h_count[node[index + 1]];
1554 numhnodes++;
1555 }
1556
1557 cin.numhnodes1[prev] = numhnodes - 1;
1558 }
1559 }
1560
1561 /**
1562 * Huff1Decompress

Callers 1

PlayCinematicMethod · 0.95

Calls 2

SmallestNode1Method · 0.95
getMethod · 0.45

Tested by

no test coverage detected