28 #define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
29 #define DEPTHOF(zz1) ((zz1) & 0x000000ff)
30 #define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
32 #define ADDWEIGHTS(zw1,zw2) \
33 (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \
34 (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
39 zz = z; tmp = heap[zz]; \
40 while (weight[tmp] < weight[heap[zz >> 1]]) { \
41 heap[zz] = heap[zz >> 1]; \
50 zz = z; tmp = heap[zz]; \
53 if (yy > nHeap) break; \
55 weight[heap[yy+1]] < weight[heap[yy]]) \
57 if (weight[tmp] < weight[heap[yy]]) break; \
58 heap[zz] = heap[yy]; \
75 Int32 nNodes, nHeap, n1, n2, i, j, k;
82 for (i = 0; i < alphaSize; i++)
83 weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
94 for (i = 1; i <= alphaSize; i++) {
104 n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--;
DOWNHEAP(1);
105 n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--;
DOWNHEAP(1);
107 parent[n1] = parent[n2] = nNodes;
108 weight[nNodes] =
ADDWEIGHTS(weight[n1], weight[n2]);
111 heap[nHeap] = nNodes;
118 for (i = 1; i <= alphaSize; i++) {
121 while (parent[k] >= 0) { k = parent[k]; j++; }
123 if (j > maxLen) tooLong =
True;
126 if (! tooLong)
break;
145 for (i = 1; i <= alphaSize; i++) {
164 for (n = minLen; n <= maxLen; n++) {
165 for (i = 0; i < alphaSize; i++)
166 if (length[i] == n) { code[i] = vec; vec++; };
184 for (i = minLen; i <= maxLen; i++)
185 for (j = 0; j < alphaSize; j++)
186 if (length[j] == i) { perm[pp] = j; pp++; };
189 for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
196 for (i = minLen; i <= maxLen; i++) {
197 vec += (base[i+1] - base[i]);
201 for (i = minLen + 1; i <= maxLen; i++)
202 base[i] = ((limit[i-1] + 1) << 1) - base[i];
#define ADDWEIGHTS(zw1, zw2)
void BZ2_hbAssignCodes(Int32 *code, UChar *length, Int32 minLen, Int32 maxLen, Int32 alphaSize)
void BZ2_hbMakeCodeLengths(UChar *len, Int32 *freq, Int32 alphaSize, Int32 maxLen)
#define AssertH(cond, errcode)
#define ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_START
#define BZ_MAX_ALPHA_SIZE
void BZ2_hbCreateDecodeTables(Int32 *limit, Int32 *base, Int32 *perm, UChar *length, Int32 minLen, Int32 maxLen, Int32 alphaSize)