11 const Byte PPMD7_kExpEscape[16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 };
12 static const UInt16 kInitBinEsc[] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051};
17 #define U2B(nu) ((UInt32)(nu) * UNIT_SIZE)
18 #define U2I(nu) (p->Units2Indx[(size_t)(nu) - 1])
19 #define I2U(indx) (p->Indx2Units[indx])
22 #define REF(ptr) (ptr)
24 #define REF(ptr) ((UInt32)((Byte *)(ptr) - (p)->Base))
27 #define STATS_REF(ptr) ((CPpmd_State_Ref)REF(ptr))
29 #define CTX(ref) ((CPpmd7_Context *)Ppmd7_GetContext(p, ref))
30 #define STATS(ctx) Ppmd7_GetStats(p, ctx)
31 #define ONE_STATE(ctx) Ppmd7Context_OneState(ctx)
32 #define SUFFIX(ctx) CTX((ctx)->Suffix)
55 #define NODE(ptr) (ptr)
57 #define NODE(offs) ((CPpmd7_Node *)(p->Base + (offs)))
68 unsigned step = (i >= 12 ? 4 : (i >> 2) + 1);
76 memset(p->
NS2BSIndx + 11, (3 << 1), 256 - 11);
78 for (i = 0; i < 3; i++)
80 for (m = i, k = 1; i < 256; i++)
88 memset(p->
HB2Flag + 0x40, 8, 0x100 - 0x40);
137 unsigned i, nu =
I2U(oldIndx) -
I2U(newIndx);
139 if (
I2U(i =
U2I(nu)) != nu)
141 unsigned k =
I2U(--i);
171 n =
NODE(n)->Prev = next;
177 NODE(head)->Stamp = 1;
178 NODE(head)->Next = n;
179 NODE(n)->Prev = head;
192 if (node2->
Stamp != 0 || nu >= 0x10000)
202 for (n =
NODE(head)->Next; n != head;)
207 for (nu = node->
NU; nu > 128; nu -= 128, node += 128)
209 if (
I2U(i =
U2I(nu)) != nu)
211 unsigned k =
I2U(--i);
250 numBytes =
U2B(
I2U(indx));
260 #define MyMem12Cpy(dest, src, num) \
261 { UInt32 *d = (UInt32 *)dest; const UInt32 *s = (const UInt32 *)src; UInt32 n = num; \
262 do { d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; s += 3; d += 3; } while (--n); }
266 unsigned i0 =
U2I(oldNU);
267 unsigned i1 =
U2I(newNU);
281 #define SUCCESSOR(p) ((CPpmd_Void_Ref)((p)->SuccessorLow | ((UInt32)(p)->SuccessorHigh << 16)))
286 (p)->SuccessorHigh = (
UInt16)(((
UInt32)(v) >> 16) & 0xFFFF);
310 for (i = 0; i < 256; i++)
318 for (i = 0; i < 128; i++)
319 for (k = 0; k < 8; k++)
323 for (m = 0; m < 64; m += 8)
327 for (i = 0; i < 25; i++)
328 for (k = 0; k < 16; k++)
368 if (successor != upBranch)
390 upState.
Freq = (
Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) : ((2 * cf + 3 * s0 - 1) / (2 * s0))));
447 if (s[0].Freq >= s[-1].Freq)
483 if (fSuccessor <= successor)
491 fSuccessor =
REF(cs);
495 successor = fSuccessor;
516 unsigned oldNU = ns1 >> 1;
517 unsigned i =
U2I(oldNU);
518 if (i !=
U2I((
size_t)oldNU + 1))
555 cf = 1 + (cf > sf) + (cf >= 4 * sf);
560 cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf);
576 unsigned i, adder, sumFreq, escFreq;
581 for (; s != stats; s--)
594 escFreq -= (++s)->Freq;
597 if (s[0].Freq > s[-1].Freq)
603 while (--s1 != stats && tmp.
Freq > s1[-1].
Freq);
613 do { i++; }
while ((--s)->Freq == 0);
629 n0 = (numStats + 1) >> 1;
644 see = p->
See[(unsigned)p->
NS2Indx[(
size_t)nonMasked - 1]] +
647 4 * (
unsigned)(numMasked > nonMasked) +
652 *escFreq = r + (r == 0);
677 if (s[0].Freq > s[-1].Freq)